summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorMichiel Van Der Kolk <not.valid@email.address>2005-07-01 17:29:44 +0000
committerMichiel Van Der Kolk <not.valid@email.address>2005-07-01 17:29:44 +0000
commitc735ed79142a0260fc05d58cb0672e5d1720a26a (patch)
tree3fd67eb9fb598e9b8bc0c3003ec3bf037379ebb4 /apps/plugins
parent4ec80704d5f34a167d45db7539f47b12cc23c59e (diff)
downloadrockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.tar.gz
rockbox-c735ed79142a0260fc05d58cb0672e5d1720a26a.zip
First runtime database support, self repairing, only playcount works for now,
which is still rather crude; playcount gets increased even if the song started playback but was skipped... track rating should be trivial to add, autorating also works since its based on playcount. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6969 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/databox/edittoken.h2
-rw-r--r--apps/plugins/searchengine/dbinterface.c15
-rw-r--r--apps/plugins/searchengine/dbinterface.h8
-rw-r--r--apps/plugins/searchengine/token.h9
4 files changed, 23 insertions, 11 deletions
diff --git a/apps/plugins/databox/edittoken.h b/apps/plugins/databox/edittoken.h
index 77c948b2af..2fcb874995 100644
--- a/apps/plugins/databox/edittoken.h
+++ b/apps/plugins/databox/edittoken.h
@@ -88,7 +88,7 @@
88 88
89struct token { 89struct token {
90 char kind; 90 char kind;
91 char spelling[SPELLING_LENGTH + 1]; 91 char spelling[SPELLING_LENGTH + 3];
92 long intvalue; 92 long intvalue;
93}; 93};
94char *tokentypetostring(int tokentype); 94char *tokentypetostring(int tokentype);
diff --git a/apps/plugins/searchengine/dbinterface.c b/apps/plugins/searchengine/dbinterface.c
index c098079e35..e10510604d 100644
--- a/apps/plugins/searchengine/dbinterface.c
+++ b/apps/plugins/searchengine/dbinterface.c
@@ -29,6 +29,7 @@
29#define FILEENTRY_SIZE (rb->tagdbheader->filelen+12) 29#define FILEENTRY_SIZE (rb->tagdbheader->filelen+12)
30#define ALBUMENTRY_SIZE (rb->tagdbheader->albumlen+4+rb->tagdbheader->songarraylen*4) 30#define ALBUMENTRY_SIZE (rb->tagdbheader->albumlen+4+rb->tagdbheader->songarraylen*4)
31#define ARTISTENTRY_SIZE (rb->tagdbheader->artistlen+rb->tagdbheader->albumarraylen*4) 31#define ARTISTENTRY_SIZE (rb->tagdbheader->artistlen+rb->tagdbheader->albumarraylen*4)
32#define RUNDBENTRY_SIZE 20
32 33
33#define FILERECORD2OFFSET(_x_) (rb->tagdbheader->filestart + _x_ * FILEENTRY_SIZE) 34#define FILERECORD2OFFSET(_x_) (rb->tagdbheader->filestart + _x_ * FILEENTRY_SIZE)
34 35
@@ -45,7 +46,7 @@ int database_init() {
45 // zero all entries. 46 // zero all entries.
46 for(i=0;i<sizeof(struct entry)*rb->tagdbheader->filecount;i++) 47 for(i=0;i<sizeof(struct entry)*rb->tagdbheader->filecount;i++)
47 *(p++)=0; 48 *(p++)=0;
48 if(*rb->tagdb_initialized!=1) { 49 if(!*rb->tagdb_initialized) {
49 if(!rb->tagdb_init()) { 50 if(!rb->tagdb_init()) {
50 // failed loading db 51 // failed loading db
51 return -1; 52 return -1;
@@ -110,8 +111,18 @@ void loadsongdata() {
110} 111}
111 112
112void loadrundbdata() { 113void loadrundbdata() {
113 // we don't do this yet.
114 currententry->loadedrundbdata=1; 114 currententry->loadedrundbdata=1;
115 if(!*rb->rundb_initialized)
116 return;
117 if(currententry->rundbentry==-1)
118 return;
119 rb->lseek(*rb->rundb_fd,currententry->rundbentry,SEEK_SET);
120 currententry->rundbfe=readlong(*rb->rundb_fd);
121 currententry->rundbhash=readlong(*rb->rundb_fd);
122 currententry->rating=readshort(*rb->rundb_fd);
123 currententry->voladj=readshort(*rb->rundb_fd);
124 currententry->playcount=readlong(*rb->rundb_fd);
125 currententry->lastplayed=readlong(*rb->rundb_fd);
115} 126}
116 127
117void loadartistname() { 128void loadartistname() {
diff --git a/apps/plugins/searchengine/dbinterface.h b/apps/plugins/searchengine/dbinterface.h
index 98596aed2f..b168456b85 100644
--- a/apps/plugins/searchengine/dbinterface.h
+++ b/apps/plugins/searchengine/dbinterface.h
@@ -30,13 +30,15 @@ struct entry {
30 loadedalbumname, 30 loadedalbumname,
31 loadedartistname; 31 loadedartistname;
32 char *filename; 32 char *filename;
33 long hash; 33 long hash,rundbhash;
34 long songentry; 34 long songentry,rundbfe;
35 long rundbentry; 35 long rundbentry;
36 short year; 36 short year;
37 short bitrate; 37 short bitrate;
38 long rating; 38 short rating;
39 long playcount; 39 long playcount;
40 long lastplayed;
41 short voladj;
40 char *title; 42 char *title;
41 char *genre; 43 char *genre;
42 long artistoffset; 44 long artistoffset;
diff --git a/apps/plugins/searchengine/token.h b/apps/plugins/searchengine/token.h
index cd337690bb..6deecd81a5 100644
--- a/apps/plugins/searchengine/token.h
+++ b/apps/plugins/searchengine/token.h
@@ -54,13 +54,12 @@
54#define INTVALUE_GENRE 17 54#define INTVALUE_GENRE 17
55#define INTVALUE_FILENAME 18 55#define INTVALUE_FILENAME 18
56 56
57/* static char *spelling[] = { "not", "and", "or",">",">=","<", "<=","==","!=", 57#define SPELLING_LENGTH 100
58 "contains","(",")" }; */
59 58
60struct token { 59struct token {
61 unsigned char kind; 60 char kind;
62 char spelling[255]; // 255 should make it aligned again.. 61 char spelling[SPELLING_LENGTH + 3];
63 long intvalue; 62 long intvalue;
64}; 63};
65 64
66char *getstring(struct token *token); 65char *getstring(struct token *token);