speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] server - Add support for retrieving current voice and curren


From: Luke Yelavich
Subject: [PATCH 2/3] server - Add support for retrieving current voice and current output module over SSIP
Date: Mon, 27 Jul 2009 16:20:26 +1000

From: Luke Yelavich <address@hidden>
To: address@hidden

Thanks to Jeremy Whiting <jeremy at scitools.com> for the patch.
---
 src/server/msg.h   |    2 +
 src/server/parse.c |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/server/parse.h |    1 +
 3 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/server/msg.h b/src/server/msg.h
index ae3c41e..36c8fc6 100644
--- a/src/server/msg.h
+++ b/src/server/msg.h
@@ -77,6 +77,8 @@
 #define C_OK_VOICES                             "249"
 #define OK_MODULES_LIST_SENT                    "250 OK VOICE LIST SENT\r\n"
 #define C_OK_MODULES                            "250"
+#define OK_GET                                  "251 OK GET RETURNED\r\n"
+#define C_OK_GET                                "251"
 
 #define OK_INSIDE_BLOCK                         "260 OK INSIDE BLOCK\r\n"
 #define OK_OUTSIDE_BLOCK                        "261 OK OUTSIDE BLOCK\r\n"
diff --git a/src/server/parse.c b/src/server/parse.c
index a83a827..36214ef 100644
--- a/src/server/parse.c
+++ b/src/server/parse.c
@@ -104,6 +104,7 @@ parse(const char *buf, const int bytes, const int fd)
         CHECK_SSIP_COMMAND("char", parse_char, BLOCK_OK);
         CHECK_SSIP_COMMAND("key", parse_key, BLOCK_OK)
         CHECK_SSIP_COMMAND("list", parse_list, BLOCK_NO);
+        CHECK_SSIP_COMMAND("get", parse_get, BLOCK_NO);
         CHECK_SSIP_COMMAND("help", parse_help, BLOCK_NO);              
         CHECK_SSIP_COMMAND("block", parse_block, BLOCK_OK);
 
@@ -879,6 +880,72 @@ parse_list(const char* buf, const int bytes, const int fd)
 }
 
 char*
+parse_get(const char *buf, const int bytes, const int fd)
+{
+    char *get_type;
+    GString *result;
+    char *helper;
+
+    TFDSetElement *settings;
+
+    settings = get_client_settings_by_fd(fd);
+    if (settings == NULL) 
+        return strdup(ERR_INTERNAL);
+
+    GET_PARAM_STR(get_type, 1, CONV_DOWN);
+    if(TEST_CMD(get_type, "voice")) {
+        result = g_string_new("");
+
+        switch (settings->voice)
+        {
+            case MALE1:
+                g_string_append_printf(result, C_OK_GET"-MALE1\r\n");
+                break;
+            case MALE2:
+                g_string_append_printf(result, C_OK_GET"-MALE2\r\n");
+                break;
+            case MALE3:
+                g_string_append_printf(result, C_OK_GET"-MALE3\r\n");
+                break;
+            case FEMALE1:
+                g_string_append_printf(result, C_OK_GET"-FEMALE1\r\n");
+                break;
+            case FEMALE2:
+                g_string_append_printf(result, C_OK_GET"-FEMALE2\r\n");
+                break;
+            case FEMALE3:
+                g_string_append_printf(result, C_OK_GET"-FEMALE3\r\n");
+                break;
+            case CHILD_MALE:
+                g_string_append_printf(result, C_OK_GET"-CHILD_MALE\r\n");
+                break;
+            case CHILD_FEMALE:
+                g_string_append_printf(result, C_OK_GET"-CHILD_FEMALE\r\n");
+                break;
+            case NO_VOICE:
+            default:
+                g_string_append_printf(result, C_OK_GET"-NO_VOICE\r\n");
+                break;
+        }
+        helper = result->str;
+        g_string_free(result, 0);
+        return helper;
+    }
+    else if (TEST_CMD(get_type, "output_module")) {
+        result = g_string_new("");
+        g_string_append_printf(result, C_OK_GET"-%s\r\n",
+                       settings->output_module);
+        helper = result->str;
+        g_string_free(result, 0);
+        return helper;      
+    }
+    else{
+      spd_free(get_type);
+      return strdup(ERR_PARAMETER_INVALID);
+    }
+}
+
+char*
 parse_help(const char* buf, const int bytes, const int fd)
 {
     char *help;
@@ -891,6 +958,7 @@ parse_help(const char* buf, const int bytes, const int fd)
             C_OK_HELP"-  CHAR            -- say a character \r\n"
             C_OK_HELP"-  SOUND_ICON      -- execute a sound icon \r\n"
             C_OK_HELP"-  SET             -- set a parameter \r\n"
+            C_OK_HELP"-  GET             -- get a current parameter \r\n"
             C_OK_HELP"-  LIST            -- list available arguments \r\n"
             C_OK_HELP"-  HISTORY         -- commands related to history \r\n"
             C_OK_HELP"-  QUIT            -- close the connection \r\n"
diff --git a/src/server/parse.h b/src/server/parse.h
index a50d631..2201d03 100644
--- a/src/server/parse.h
+++ b/src/server/parse.h
@@ -14,6 +14,7 @@ char* parse_snd_icon(const char* buf, const int bytes, const 
int fd);
 char* parse_char(const char* buf, const int bytes, const int fd);
 char* parse_key(const char* buf, const int bytes, const int fd);
 char* parse_list(const char* buf, const int bytes, const int fd);
+char* parse_get(const char* buf, const int bytes, const int fd);
 char* parse_help(const char* buf, const int bytes, const int fd);
 char* parse_block(const char* buf, const int bytes, const int fd);
 
-- 
1.6.3.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]