summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/talk.c31
-rw-r--r--apps/talk.h4
-rw-r--r--apps/tree.c6
-rw-r--r--firmware/common/pathfuncs.c30
-rw-r--r--firmware/export/pathfuncs.h1
5 files changed, 68 insertions, 4 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 2e73001c46..ab4a97397c 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -44,6 +44,7 @@
44#include "debug.h" 44#include "debug.h"
45#include "panic.h" 45#include "panic.h"
46#include "misc.h" /* time_split_units() */ 46#include "misc.h" /* time_split_units() */
47#include "mv.h"
47 48
48/***************** Constants *****************/ 49/***************** Constants *****************/
49 50
@@ -1167,6 +1168,21 @@ int talk_file_or_spell(const char *dirname, const char *filename,
1167 return 0; 1168 return 0;
1168} 1169}
1169 1170
1171#ifdef HAVE_MULTIVOLUME
1172int talk_volume_id(int volume)
1173{
1174 if (volume == -1)
1175 return 0;
1176
1177 int drive = volume_drive(volume);
1178 // XXX voice "VOLUME" or something like that?
1179
1180 talk_id(drive? LANG_DISK_NAME_MMC : LANG_DISK_NAME_INTERNAL, true);
1181 talk_value(volume, UNIT_INT, true);
1182 return 1;
1183}
1184#endif
1185
1170/* Play a directory's .talk thumbnail, fallback to spelling the filename, or 1186/* Play a directory's .talk thumbnail, fallback to spelling the filename, or
1171 go straight to spelling depending on settings. */ 1187 go straight to spelling depending on settings. */
1172int talk_dir_or_spell(const char* dirname, 1188int talk_dir_or_spell(const char* dirname,
@@ -1174,13 +1190,14 @@ int talk_dir_or_spell(const char* dirname,
1174{ 1190{
1175 if (global_settings.talk_dir_clip) 1191 if (global_settings.talk_dir_clip)
1176 { /* .talk clips enabled */ 1192 { /* .talk clips enabled */
1177 if(talk_file(dirname, NULL, dir_thumbnail_name, NULL, 1193 if (talk_file(dirname, NULL, dir_thumbnail_name, NULL,
1178 prefix_ids, enqueue) >0) 1194 prefix_ids, enqueue) >0)
1179 return 0; 1195 return 0;
1180 } 1196 }
1181 if (global_settings.talk_dir == TALK_SPEAK_SPELL) 1197 if (global_settings.talk_dir == TALK_SPEAK_SPELL) {
1182 /* Either .talk clips disabled or as a fallback */ 1198 /* Either .talk clips disabled or as a fallback */
1183 return talk_spell_basename(dirname, prefix_ids, enqueue); 1199 return talk_spell_basename(dirname, prefix_ids, enqueue);
1200 }
1184 return 0; 1201 return 0;
1185} 1202}
1186 1203
@@ -1201,12 +1218,20 @@ int talk_fullpath(const char* path, bool enqueue)
1201 while(ptr) { /* There are more slashes ahead */ 1218 while(ptr) { /* There are more slashes ahead */
1202 /* temporarily poke a NULL at end of component to truncate string */ 1219 /* temporarily poke a NULL at end of component to truncate string */
1203 *ptr = '\0'; 1220 *ptr = '\0';
1204 talk_dir_or_spell(buf, NULL, true); 1221#ifdef HAVE_MULTIVOLUME
1222 if (start == buf+1) {
1223 int vol = path_get_volume_id(buf+1);
1224 if (!talk_volume_id(vol))
1225 talk_dir_or_spell(buf, NULL, true);
1226 } else
1227#endif
1228 talk_dir_or_spell(buf, NULL, true);
1205 *ptr = '/'; /* restore string */ 1229 *ptr = '/'; /* restore string */
1206 talk_id(VOICE_CHAR_SLASH, true); 1230 talk_id(VOICE_CHAR_SLASH, true);
1207 start = ptr+1; /* setup for next component */ 1231 start = ptr+1; /* setup for next component */
1208 ptr = strchr(start, '/'); 1232 ptr = strchr(start, '/');
1209 } 1233 }
1234
1210 /* no more slashes, final component is a filename */ 1235 /* no more slashes, final component is a filename */
1211 return talk_file_or_spell(NULL, buf, NULL, true); 1236 return talk_file_or_spell(NULL, buf, NULL, true);
1212} 1237}
diff --git a/apps/talk.h b/apps/talk.h
index 6139b9ec46..507d5cbed1 100644
--- a/apps/talk.h
+++ b/apps/talk.h
@@ -145,6 +145,10 @@ void talk_fractional(char *tbuf, int value, int unit);
145void talk_time(const struct tm *tm, bool enqueue); 145void talk_time(const struct tm *tm, bool enqueue);
146void talk_date(const struct tm *tm, bool enqueue); 146void talk_date(const struct tm *tm, bool enqueue);
147 147
148#ifdef HAVE_MULTIVOLUME
149int talk_volume_id(int volume);
150#endif
151
148/* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */ 152/* speaks hr, min, sec, ms; unit_idx is lowest or base unit of the time value */
149int talk_time_intervals(long time, int unit_idx, bool enqueue); 153int talk_time_intervals(long time, int unit_idx, bool enqueue);
150 154
diff --git a/apps/tree.c b/apps/tree.c
index 8c41abbdcf..71a7ee3f62 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -1252,6 +1252,12 @@ static void say_filetype(int attr)
1252 1252
1253static int ft_play_dirname(char* name) 1253static int ft_play_dirname(char* name)
1254{ 1254{
1255#ifdef HAVE_MULTIVOLUME
1256 int vol = path_get_volume_id(name);
1257 if (talk_volume_id(vol))
1258 return 1;
1259#endif
1260
1255 return talk_file(tc.currdir, name, dir_thumbnail_name, NULL, 1261 return talk_file(tc.currdir, name, dir_thumbnail_name, NULL,
1256 global_settings.talk_filetype ? 1262 global_settings.talk_filetype ?
1257 TALK_IDARRAY(VOICE_DIR) : NULL, 1263 TALK_IDARRAY(VOICE_DIR) : NULL,
diff --git a/firmware/common/pathfuncs.c b/firmware/common/pathfuncs.c
index db1935db8b..b5e5ecb0cf 100644
--- a/firmware/common/pathfuncs.c
+++ b/firmware/common/pathfuncs.c
@@ -127,7 +127,35 @@ void init_volume_names(void)
127 VOL_START_TOK, voldec, volume, VOL_END_TOK); 127 VOL_START_TOK, voldec, volume, VOL_END_TOK);
128 DEBUGF("vol<%d> = %s ", volume, buffer); 128 DEBUGF("vol<%d> = %s ", volume, buffer);
129 } 129 }
130 DEBUGF("\n"); 130 DEBUGF("\n");
131}
132
133#include <stdio.h>
134
135int path_get_volume_id(const char *name)
136{
137 int v = -1;
138
139 if (!name || *name != VOL_START_TOK)
140 goto bail;
141
142 do {
143 switch (*name)
144 {
145 case '0' ... '9': /* digit; parse volume number */
146 v = (v * 10 + *name - '0') % VOL_NUM_MAX;
147 break;
148 case '\0':
149 case PATH_SEPCH: /* no closing bracket; no volume */
150 v = -1;
151 goto bail;
152 default: /* something else; reset volume */
153 v = 0;
154 }
155 } while (*++name != VOL_END_TOK); /* found end token? */
156
157bail:
158 return v;
131} 159}
132 160
133/* Returns on which volume this is and sets *nameptr to the portion of the 161/* Returns on which volume this is and sets *nameptr to the portion of the
diff --git a/firmware/export/pathfuncs.h b/firmware/export/pathfuncs.h
index 73f20f9a52..fce8e5851c 100644
--- a/firmware/export/pathfuncs.h
+++ b/firmware/export/pathfuncs.h
@@ -83,6 +83,7 @@ int path_strip_last_volume(const char *name, const char **nameptr, bool greedy);
83int get_volume_name(int volume, char *name); 83int get_volume_name(int volume, char *name);
84int make_volume_root(int volume, char *dst); 84int make_volume_root(int volume, char *dst);
85void init_volume_names(void); 85void init_volume_names(void);
86int path_get_volume_id(const char *name);
86#endif 87#endif
87 88
88int path_strip_drive(const char *name, const char **nameptr, bool greedy); 89int path_strip_drive(const char *name, const char **nameptr, bool greedy);