2005-04-28 14:06:20 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 by Michiel van der Kolk
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-04-28 14:06:20 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2005-04-28 18:49:23 +00:00
|
|
|
#include "searchengine.h"
|
2005-04-28 12:33:38 +00:00
|
|
|
#include "token.h"
|
|
|
|
#include "dbinterface.h"
|
|
|
|
|
|
|
|
char *getstring(struct token *token) {
|
2005-04-29 23:57:50 +00:00
|
|
|
char buf[200];
|
2005-04-29 21:02:17 +00:00
|
|
|
switch(token->kind) {
|
|
|
|
case TOKEN_STRING:
|
|
|
|
return token->spelling;
|
|
|
|
case TOKEN_STRINGIDENTIFIER:
|
|
|
|
switch(token->intvalue) {
|
|
|
|
case INTVALUE_TITLE:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->title;
|
|
|
|
case INTVALUE_ARTIST:
|
|
|
|
loadartistname();
|
|
|
|
return currententry->artistname;
|
|
|
|
case INTVALUE_ALBUM:
|
|
|
|
loadalbumname();
|
|
|
|
return currententry->albumname;
|
|
|
|
case INTVALUE_GENRE:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->genre;
|
|
|
|
case INTVALUE_FILENAME:
|
|
|
|
return currententry->filename;
|
|
|
|
default:
|
2005-04-29 23:57:50 +00:00
|
|
|
rb->snprintf(buf,199,"unknown stringid intvalue %d",token->intvalue);
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2,buf);
|
2005-04-29 23:57:50 +00:00
|
|
|
return "";
|
2005-04-29 21:02:17 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// report error
|
2005-04-29 23:57:50 +00:00
|
|
|
rb->snprintf(buf,199,"unknown token %d in getstring..",token->kind);
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2,buf);
|
2005-04-29 23:57:50 +00:00
|
|
|
return "";
|
2005-04-29 21:02:17 +00:00
|
|
|
}
|
2005-04-28 12:33:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getvalue(struct token *token) {
|
2005-04-29 23:57:50 +00:00
|
|
|
char buf[200];
|
2005-05-11 00:12:33 +00:00
|
|
|
int index,i;
|
2005-04-29 21:02:17 +00:00
|
|
|
switch(token->kind) {
|
|
|
|
case TOKEN_NUM:
|
|
|
|
return token->intvalue;
|
|
|
|
case TOKEN_NUMIDENTIFIER:
|
|
|
|
switch(token->intvalue) {
|
|
|
|
case INTVALUE_YEAR:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->year;
|
|
|
|
case INTVALUE_RATING:
|
|
|
|
loadrundbdata();
|
|
|
|
return currententry->rating;
|
|
|
|
case INTVALUE_PLAYCOUNT:
|
|
|
|
loadrundbdata();
|
|
|
|
return currententry->playcount;
|
2005-06-06 19:34:35 +00:00
|
|
|
case INTVALUE_PLAYTIME:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->playtime;
|
|
|
|
case INTVALUE_TRACKNUM:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->track;
|
|
|
|
case INTVALUE_BITRATE:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->bitrate;
|
|
|
|
case INTVALUE_SAMPLERATE:
|
|
|
|
loadsongdata();
|
|
|
|
return currententry->samplerate;
|
2005-05-10 23:44:22 +00:00
|
|
|
case INTVALUE_AUTORATING:
|
2005-05-11 00:12:33 +00:00
|
|
|
if(!dbglobal.gotplaycountlimits) {
|
|
|
|
index=dbglobal.currententryindex;
|
|
|
|
dbglobal.playcountmax=0;
|
|
|
|
dbglobal.playcountmin=0xFFFFFFFF;
|
|
|
|
for(i=0;i<rb->tagdbheader->filecount;i++) {
|
|
|
|
loadentry(i);
|
|
|
|
loadrundbdata();
|
|
|
|
if(currententry->playcount>dbglobal.playcountmax)
|
|
|
|
dbglobal.playcountmax=currententry->playcount;
|
|
|
|
if(currententry->playcount<dbglobal.playcountmin)
|
|
|
|
dbglobal.playcountmin=currententry->playcount;
|
|
|
|
}
|
|
|
|
dbglobal.gotplaycountlimits=1;
|
|
|
|
loadentry(index);
|
|
|
|
}
|
|
|
|
loadrundbdata();
|
|
|
|
return (currententry->playcount-dbglobal.playcountmin)*10/(dbglobal.playcountmax-dbglobal.playcountmin);
|
2005-04-29 21:02:17 +00:00
|
|
|
default:
|
2005-04-29 23:57:50 +00:00
|
|
|
rb->snprintf(buf,199,"unknown numid intvalue %d",token->intvalue);
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2,buf);
|
2005-04-29 21:02:17 +00:00
|
|
|
// report error.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
default:
|
2005-04-29 23:57:50 +00:00
|
|
|
rb->snprintf(buf,199,"unknown token %d in getvalue..",token->kind);
|
2007-03-16 21:56:08 +00:00
|
|
|
rb->splash(HZ*2,buf);
|
2005-04-29 21:02:17 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-28 12:33:38 +00:00
|
|
|
}
|