Added support for very large tables in ID3 database.
[kugel-rb.git] / apps / tree.h
blob87364bfd5ac7565d44b3035c0eaccd67d0bef4ad
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Daniel Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #ifndef _TREE_H_
20 #define _TREE_H_
22 #include <stdbool.h>
23 #include <applimits.h>
24 #include <file.h>
26 #if CONFIG_KEYPAD == IRIVER_H100_PAD
27 #define TREE_NEXT BUTTON_DOWN
28 #define TREE_PREV BUTTON_UP
29 #define TREE_EXIT BUTTON_LEFT
30 #define TREE_ENTER BUTTON_RIGHT
31 #define TREE_RUN (BUTTON_SELECT | BUTTON_REL)
32 #define TREE_RUN_PRE BUTTON_SELECT
33 #define TREE_MENU BUTTON_MODE
34 #define TREE_OFF BUTTON_OFF
35 #define TREE_WPS (BUTTON_ON | BUTTON_REL)
36 #define TREE_WPS_PRE BUTTON_ON
37 #define TREE_PGUP (BUTTON_ON | BUTTON_UP)
38 #define TREE_PGDN (BUTTON_ON | BUTTON_DOWN)
39 #define TREE_CONTEXT (BUTTON_SELECT | BUTTON_REPEAT)
40 #define TREE_CONTEXT2 (BUTTON_ON | BUTTON_SELECT)
41 #define TREE_POWER_BTN BUTTON_ON
43 #elif CONFIG_KEYPAD == RECORDER_PAD
44 #define TREE_NEXT BUTTON_DOWN
45 #define TREE_PREV BUTTON_UP
46 #define TREE_EXIT BUTTON_LEFT
47 #define TREE_ENTER BUTTON_RIGHT
48 #define TREE_RUN (BUTTON_PLAY | BUTTON_REL)
49 #define TREE_RUN_PRE BUTTON_PLAY
50 #define TREE_MENU BUTTON_F1
51 #define TREE_OFF BUTTON_OFF
52 #define TREE_WPS (BUTTON_ON | BUTTON_REL)
53 #define TREE_WPS_PRE BUTTON_ON
54 #define TREE_PGUP (BUTTON_ON | BUTTON_UP)
55 #define TREE_PGDN (BUTTON_ON | BUTTON_DOWN)
56 #define TREE_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT)
57 #define TREE_CONTEXT2 (BUTTON_ON | BUTTON_PLAY)
58 #define TREE_POWER_BTN BUTTON_ON
60 #define TREE_RC_NEXT BUTTON_RC_RIGHT
61 #define TREE_RC_PREV BUTTON_RC_LEFT
62 #define TREE_RC_EXIT BUTTON_RC_STOP
63 #define TREE_RC_ENTER BUTTON_RC_PLAY
64 #define TREE_RC_RUN BUTTON_RC_PLAY
66 #elif CONFIG_KEYPAD == PLAYER_PAD
67 #define TREE_NEXT BUTTON_RIGHT
68 #define TREE_PREV BUTTON_LEFT
69 #define TREE_EXIT BUTTON_STOP
70 #define TREE_RUN (BUTTON_PLAY | BUTTON_REL)
71 #define TREE_RUN_PRE BUTTON_PLAY
72 #define TREE_MENU BUTTON_MENU
73 #define TREE_WPS (BUTTON_ON | BUTTON_REL)
74 #define TREE_WPS_PRE BUTTON_ON
75 #define TREE_CONTEXT (BUTTON_PLAY | BUTTON_REPEAT)
76 #define TREE_CONTEXT2 (BUTTON_ON | BUTTON_PLAY)
77 #define TREE_POWER_BTN BUTTON_ON
79 #define TREE_RC_NEXT BUTTON_RC_RIGHT
80 #define TREE_RC_PREV BUTTON_RC_LEFT
81 #define TREE_RC_EXIT BUTTON_RC_STOP
82 #define TREE_RC_ENTER BUTTON_RC_PLAY
83 #define TREE_RC_RUN BUTTON_RC_PLAY
85 #elif CONFIG_KEYPAD == ONDIO_PAD
86 #define TREE_NEXT BUTTON_DOWN
87 #define TREE_PREV BUTTON_UP
88 #define TREE_EXIT BUTTON_LEFT
89 #define TREE_RUN (BUTTON_RIGHT | BUTTON_REL)
90 #define TREE_RUN_PRE BUTTON_RIGHT
91 #define TREE_MENU (BUTTON_MENU | BUTTON_REPEAT)
92 #define TREE_MENU_PRE BUTTON_MENU
93 #define TREE_WPS (BUTTON_MENU | BUTTON_REL)
94 #define TREE_WPS_PRE BUTTON_MENU
95 #define TREE_CONTEXT (BUTTON_RIGHT | BUTTON_REPEAT)
96 #define TREE_POWER_BTN BUTTON_OFF
98 #endif
100 #ifdef HAVE_LCD_BITMAP
101 #define BOOTFILE "ajbrec.ajz"
102 #else
103 #define BOOTFILE "archos.mod"
104 #endif
106 struct entry {
107 short attr; /* FAT attributes + file type flags */
108 unsigned long time_write; /* Last write time */
109 char *name;
112 struct filetype {
113 char* extension;
114 int tree_attr;
115 int icon;
116 int voiceclip;
119 /* browser context for file or db */
120 struct tree_context {
121 int dirlevel;
122 int dircursor;
123 int dirstart;
124 int firstpos; /* which dir entry is on first
125 position in dir buffer */
126 int pos_history[MAX_DIR_LEVELS];
127 int dirpos[MAX_DIR_LEVELS];
128 int cursorpos[MAX_DIR_LEVELS];
129 char currdir[MAX_PATH]; /* file use */
130 int *dirfilter; /* file use */
131 int filesindir;
132 int dirsindir; /* file use */
133 int dirlength; /* total number of entries in dir, incl. those not loaded */
134 int table_history[MAX_DIR_LEVELS]; /* db use */
135 int extra_history[MAX_DIR_LEVELS]; /* db use */
136 int currtable; /* db use */
137 int currextra; /* db use */
139 void* dircache;
140 int dircache_size;
141 char* name_buffer;
142 int name_buffer_size;
143 int dentry_size;
144 bool dirfull;
147 /* using attribute bits not used by FAT (FAT uses lower 7) */
149 #define TREE_ATTR_THUMBNAIL 0x0080 /* corresponding .talk file exists */
151 /* (this also reflects the sort order if by type) */
152 #define TREE_ATTR_BMARK 0x0100 /* book mark file */
153 #define TREE_ATTR_M3U 0x0200 /* playlist */
154 #define TREE_ATTR_MPA 0x0300 /* mpeg audio file */
155 #define TREE_ATTR_CFG 0x0400 /* config file */
156 #define TREE_ATTR_WPS 0x0500 /* wps config file */
157 #define TREE_ATTR_FONT 0x0600 /* font file */
158 #define TREE_ATTR_LNG 0x0700 /* binary lang file */
159 #define TREE_ATTR_ROCK 0x0800 /* binary rockbox plugin */
160 #define TREE_ATTR_MOD 0x0900 /* firmware file */
161 #define TREE_ATTR_MASK 0xFF00 /* which bits tree.c uses for file types */
163 void tree_get_filetypes(const struct filetype**, int*);
164 void tree_init(void);
165 void browse_root(void);
166 void set_current_file(char *path);
167 bool rockbox_browse(const char *root, int dirfilter);
168 bool create_playlist(void);
169 void resume_directory(const char *dir);
170 char *getcwd(char *buf, int size);
171 void reload_directory(void);
172 bool check_rockboxdir(void);
173 struct tree_context* tree_get_context(void);
175 #endif