diff options
Diffstat (limited to 'apps/talk.c')
-rw-r--r-- | apps/talk.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/apps/talk.c b/apps/talk.c index 2e73001c46..b5622ad6d1 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 | ||
@@ -776,7 +777,7 @@ static int _talk_spell(const char* spell, size_t len, bool enqueue) | |||
776 | talk_id(VOICE_DOT, true); | 777 | talk_id(VOICE_DOT, true); |
777 | else if (c == ' ') | 778 | else if (c == ' ') |
778 | talk_id(VOICE_PAUSE, true); | 779 | talk_id(VOICE_PAUSE, true); |
779 | else if (c == '/') | 780 | else if (c == PATH_SEPCH) |
780 | talk_id(VOICE_CHAR_SLASH, true); | 781 | talk_id(VOICE_CHAR_SLASH, true); |
781 | 782 | ||
782 | while (QUEUE_LEVEL == QUEUE_SIZE - 1) /* queue full - busy loop */ | 783 | while (QUEUE_LEVEL == QUEUE_SIZE - 1) /* queue full - busy loop */ |
@@ -1139,12 +1140,12 @@ int talk_file(const char *root, const char *dir, const char *file, | |||
1139 | { | 1140 | { |
1140 | char buf[MAX_PATH]; | 1141 | char buf[MAX_PATH]; |
1141 | const char *fmt = "%s%s%s%s%s"; | 1142 | const char *fmt = "%s%s%s%s%s"; |
1142 | /* Does root end with a slash */ | 1143 | /* Does root end with a slash? */ |
1143 | if(root && root[0] && root[strlen(root)-1] != '/') | 1144 | if(root && root[0] && root[strlen(root)-1] != PATH_SEPCH) |
1144 | fmt = "%s/%s%s%s%s"; | 1145 | fmt = "%s" PATH_SEPSTR "%s%s%s%s"; |
1145 | snprintf(buf, MAX_PATH, fmt, | 1146 | snprintf(buf, MAX_PATH, fmt, |
1146 | root ? root : "", | 1147 | root ? root : "", |
1147 | dir ? dir : "", dir ? "/" : "", | 1148 | dir ? dir : "", dir ? PATH_SEPSTR : "", |
1148 | file ? file : "", | 1149 | file ? file : "", |
1149 | ext ? ext : ""); | 1150 | ext ? ext : ""); |
1150 | return _talk_file(buf, prefix_ids, enqueue); | 1151 | return _talk_file(buf, prefix_ids, enqueue); |
@@ -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 | ||
1172 | int 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. */ |
1172 | int talk_dir_or_spell(const char* dirname, | 1188 | int 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 | ||
@@ -1190,25 +1207,43 @@ int talk_fullpath(const char* path, bool enqueue) | |||
1190 | { | 1207 | { |
1191 | do_enqueue(enqueue); /* cut off all the pending stuff */ | 1208 | do_enqueue(enqueue); /* cut off all the pending stuff */ |
1192 | 1209 | ||
1193 | if(path[0] != '/') | 1210 | if(path[0] != PATH_SEPCH) |
1194 | /* path ought to start with /... */ | 1211 | /* path ought to start with /... */ |
1195 | return talk_spell(path, true); | 1212 | return talk_spell(path, true); |
1196 | talk_id(VOICE_CHAR_SLASH, true); | 1213 | talk_id(VOICE_CHAR_SLASH, true); |
1197 | char buf[MAX_PATH]; | 1214 | char buf[MAX_PATH]; |
1198 | strmemccpy(buf, path, MAX_PATH); | 1215 | strmemccpy(buf, path, MAX_PATH); |
1199 | char *start = buf+1; /* start of current component */ | 1216 | char *start = buf+1; /* start of current component */ |
1200 | char *ptr = strchr(start, '/'); /* end of current component */ | 1217 | char *ptr = strchr(start, PATH_SEPCH); /* end of current component */ |
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 |
1205 | *ptr = '/'; /* restore string */ | 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); | ||
1229 | *ptr = PATH_SEPCH; /* 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, PATH_SEPCH); |
1233 | } | ||
1234 | |||
1235 | /* no more slashes, figure out final component */ | ||
1236 | if (!*start) { | ||
1237 | return 1; | ||
1238 | } | ||
1239 | |||
1240 | DIR* dir = opendir(buf); | ||
1241 | if (dir) { | ||
1242 | closedir(dir); | ||
1243 | return talk_dir_or_spell(buf, NULL, true); | ||
1244 | } else { | ||
1245 | return talk_file_or_spell(NULL, buf, NULL, true); | ||
1209 | } | 1246 | } |
1210 | /* no more slashes, final component is a filename */ | ||
1211 | return talk_file_or_spell(NULL, buf, NULL, true); | ||
1212 | } | 1247 | } |
1213 | 1248 | ||
1214 | /* say a numeric value, this word ordering works for english, | 1249 | /* say a numeric value, this word ordering works for english, |