summaryrefslogtreecommitdiff
path: root/apps/shortcuts.c
diff options
context:
space:
mode:
authorIgor B. Poretsky <poretsky@mlbox.ru>2015-05-18 22:51:56 +0300
committerSolomon Peachy <pizza@shaftnet.org>2019-08-13 13:08:33 +0200
commite3ed277f6813aa20876f6d4919040eaec62f9af0 (patch)
treed28418b5b772a64c5ee7261cf9cdc553da811142 /apps/shortcuts.c
parent3d06d35bf644a006c2de1c871b30e9c18888c8ec (diff)
Enhanced shortcuts speech feedback
Trying to guess proper talk clip if it is not specified explicitly. Using spelling as a fallback. Change-Id: I9eeca3fbe23086c2d8fd45360546b6afaa9c7067
Diffstat (limited to 'apps/shortcuts.c')
-rw-r--r--apps/shortcuts.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/apps/shortcuts.c b/apps/shortcuts.c
index a0b6327e54..c7e5755c1a 100644
--- a/apps/shortcuts.c
+++ b/apps/shortcuts.c
@@ -21,6 +21,7 @@
#include <stdbool.h>
#include <stdlib.h>
+#include <dir.h>
#include "config.h"
#include "system.h"
#include "powermgmt.h"
@@ -471,8 +472,74 @@ static int shortcut_menu_speak_item(int selected_item, void * data)
{
(void)data;
struct shortcut *sc = get_shortcut(selected_item);
- if (sc && sc->talk_clip[0])
- talk_file(NULL, NULL, sc->talk_clip, NULL, NULL, false);
+ if (sc)
+ {
+ if (sc->talk_clip[0])
+ {
+ talk_file(NULL, NULL, sc->talk_clip, NULL, NULL, false);
+ }
+ else
+ {
+ switch (sc->type)
+ {
+ case SHORTCUT_BROWSER:
+ {
+ static char path[MAX_PATH];
+ DIR* dir;
+ struct dirent* entry;
+ char* filename = strrchr(sc->u.path, PATH_SEPCH) + 1;
+ if (*filename != '\0')
+ {
+ int dirlen = (filename - sc->u.path);
+ strlcpy(path, sc->u.path, dirlen + 1);
+ dir = opendir(path);
+ if (dir)
+ {
+ while (0 != (entry = readdir(dir)))
+ {
+ if (!strcmp(entry->d_name, filename))
+ {
+ struct dirinfo info = dir_get_info(dir, entry);
+ if (info.attribute & ATTR_DIRECTORY)
+ talk_dir_or_spell(sc->u.path, NULL, false);
+ else talk_file_or_spell(path, filename, NULL, false);
+ return 0;
+ }
+ }
+ }
+ }
+ else
+ {
+ talk_dir_or_spell(sc->u.path, NULL, false);
+ break;
+ }
+ talk_spell(sc->u.path, false);
+ }
+ break;
+ case SHORTCUT_FILE:
+ case SHORTCUT_PLAYLISTMENU:
+ talk_file_or_spell(NULL, sc->u.path, NULL, false);
+ break;
+ case SHORTCUT_SETTING:
+ talk_id(sc->u.setting->lang_id, false);
+ break;
+#if CONFIG_RTC
+ case SHORTCUT_TIME:
+ talk_id(LANG_TIME_MENU, false);
+ break;
+#endif
+ case SHORTCUT_SHUTDOWN:
+ if (!sc->name[0])
+ {
+ talk_spell(type_strings[SHORTCUT_SHUTDOWN], false);
+ break;
+ }
+ default:
+ talk_spell(sc->name[0] ? sc->name : sc->u.path, false);
+ break;
+ }
+ }
+ }
return 0;
}