Add symbol support in direct reading 77/315277/1 accepted/tizen/8.0/unified/20240730.132327
authorŁukasz Oleksak <l.oleksak@samsung.com>
Mon, 29 Jul 2024 08:12:32 +0000 (10:12 +0200)
committerLukasz Oleksak <l.oleksak@samsung.com>
Mon, 29 Jul 2024 09:50:32 +0000 (09:50 +0000)
Change-Id: I309f657d2a3a527d3eb95b136ce3000074479e4e
(cherry picked from commit a81d7e839cce52f0913b832d97f48282abdaac1d)

src/dbus_direct_reading_adapter.c

index ed3a56f04eee213d0a021a6774449427ce1c206d..9f8d697603f2545cc219ef91df601f735b2b4260 100644 (file)
@@ -18,7 +18,9 @@
 #include "screen_reader_tts.h"
 #include "logger.h"
 #include "utils.h"
+#include "symbols.h"
 
+#include <ctype.h>
 #include <Eldbus.h>
 #include <assert.h>
 #define BUS "org.tizen.ScreenReader"
@@ -92,7 +94,7 @@ _consume_stop_command(const Eldbus_Service_Interface *iface EINA_UNUSED, const E
 static Eldbus_Message *
 _consume_read_command(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
 {
-       char *text = "";
+       const char *text = "";
        int rc_id = -1;
        Eina_Bool discardable = EINA_TRUE;
 
@@ -105,7 +107,17 @@ _consume_read_command(const Eldbus_Service_Interface *iface EINA_UNUSED, const E
                reply =  eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.Failed", "failed to parse arguments");
        } else if (reply) {
                DEBUG("RECIVED DBUS MESSAGE WITH ARGS: text(%s), discardable(%d)", text, discardable);
-               Read_Command *command = tw_speak_customized(text, EINA_TRUE, discardable, NULL, 0);
+               Eina_Strbuf *buf = eina_strbuf_new();
+               const gchar *symtext = NULL;
+               if (strlen(text) == 1 && isupper((int)*text)) {
+                       ESAF(buf, _("IDS_ACCS_OPT_CAPITAL_PS_TTS"), text);
+               } else if ((symtext = symbol_lookup(text))) {
+                       ESAL(buf, _(symtext));
+               } else {
+                       ESAL(buf, text);
+               }
+               Read_Command *command = tw_speak_customized(eina_strbuf_string_get(buf), EINA_TRUE, discardable, NULL, 0);
+               eina_strbuf_free(buf);
                if (command) rc_id = command->command_id;
                if (!eldbus_message_arguments_append(reply, "sbi", text, discardable, rc_id))
                        ERROR("eldbus_message_arguments_append() has failed to append arguments to reply message reply=%p", reply);