mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-22 20:04:52 +00:00
cleanups, remove some unnecessary var declarations and varname masking, whitespace cleanup.
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6805 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
531fe4de8f
commit
3526529f63
@ -176,12 +176,11 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
uint32_t last;
|
uint32_t last;
|
||||||
char *mydata = NULL;
|
char *mydata = NULL;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {
|
char *argv[3], *feed_list[TTS_MAX_ENTRIES] = { 0 }, *feed_names[TTS_MAX_ENTRIES] = {0};
|
||||||
0};
|
|
||||||
int argc, feed_index = 0;
|
int argc, feed_index = 0;
|
||||||
const char *cf = "rss.conf";
|
const char *cf = "rss.conf";
|
||||||
switch_xml_t cfg, cxml, feeds, feed;
|
switch_xml_t cfg, cxml, feeds, feed;
|
||||||
char buf[1024];
|
char buf[1024] = "";
|
||||||
int32_t jumpto = -1;
|
int32_t jumpto = -1;
|
||||||
uint32_t matches = 0;
|
uint32_t matches = 0;
|
||||||
switch_input_args_t args = { 0 };
|
switch_input_args_t args = { 0 };
|
||||||
@ -237,8 +236,6 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
|
|
||||||
switch_channel_answer(channel);
|
switch_channel_answer(channel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!switch_strlen_zero(data)) {
|
if (!switch_strlen_zero(data)) {
|
||||||
if ((mydata = switch_core_session_strdup(session, data))) {
|
if ((mydata = switch_core_session_strdup(session, data))) {
|
||||||
argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]));
|
argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]));
|
||||||
@ -305,7 +302,6 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
timerp = &timer;
|
timerp = &timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (switch_channel_ready(channel)) {
|
while (switch_channel_ready(channel)) {
|
||||||
int32_t len = 0, idx = 0;
|
int32_t len = 0, idx = 0;
|
||||||
char cmd[3];
|
char cmd[3];
|
||||||
@ -321,11 +317,11 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
} else {
|
} else {
|
||||||
switch_core_speech_flush_tts(&sh);
|
switch_core_speech_flush_tts(&sh);
|
||||||
#ifdef MATCH_COUNT
|
#ifdef MATCH_COUNT
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len,
|
switch_snprintf(buf + len, sizeof(buf) - len, "%s",
|
||||||
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
||||||
"Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
|
"Select one of the following news sources, or press 0 to exit. " ",<break time=\"600ms\"/>");
|
||||||
#else
|
#else
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len,
|
switch_snprintf(buf + len, sizeof(buf) - len, "%s",
|
||||||
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
",<break time=\"500ms\"/>Main Menu. <break time=\"600ms\"/> "
|
||||||
"Select one of the following news sources, followed by the pound key or press 0 to exit. " ",<break time=\"600ms\"/>");
|
"Select one of the following news sources, followed by the pound key or press 0 to exit. " ",<break time=\"600ms\"/>");
|
||||||
#endif
|
#endif
|
||||||
@ -336,8 +332,7 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
len = (int32_t) strlen(buf);
|
len = (int32_t) strlen(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_snprintf(buf + len, sizeof(buf) - len, "%s", "<break time=\"2000ms\"/>");
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "<break time=\"2000ms\"/>");
|
|
||||||
len = (int32_t) strlen(buf);
|
len = (int32_t) strlen(buf);
|
||||||
|
|
||||||
args.input_callback = NULL;
|
args.input_callback = NULL;
|
||||||
@ -349,7 +344,7 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (*cmd != '\0') {
|
if (*cmd != '\0') {
|
||||||
int32_t i;
|
int32_t x;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (strchr(cmd, '0')) {
|
if (strchr(cmd, '0')) {
|
||||||
@ -375,9 +370,9 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
|
switch_ivr_collect_digits_count(session, cp, blen, blen, "#", &term, 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = atoi(cmd) - 1;
|
x = atoi(cmd) - 1;
|
||||||
|
|
||||||
if (i > -1 && i < feed_index) {
|
if (x > -1 && x < feed_index) {
|
||||||
filename = feed_list[i];
|
filename = feed_list[i];
|
||||||
} else if (matches > 1) {
|
} else if (matches > 1) {
|
||||||
|
|
||||||
@ -396,8 +391,6 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!(xml = switch_xml_parse_file(filename))) {
|
if (!(xml = switch_xml_parse_file(filename))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", filename);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", filename);
|
||||||
goto finished;
|
goto finished;
|
||||||
@ -445,7 +438,6 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
entries[i].subject_txt = NULL;
|
entries[i].subject_txt = NULL;
|
||||||
entries[i].dept_txt = NULL;
|
entries[i].dept_txt = NULL;
|
||||||
|
|
||||||
|
|
||||||
if ((title = switch_xml_child(item, "title"))) {
|
if ((title = switch_xml_child(item, "title"))) {
|
||||||
entries[i].title_txt = title->txt;
|
entries[i].title_txt = title->txt;
|
||||||
}
|
}
|
||||||
@ -483,7 +475,6 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,7 +482,7 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
switch_time_exp_t tm;
|
switch_time_exp_t tm;
|
||||||
char date[80] = "";
|
char date[80] = "";
|
||||||
switch_size_t retsize;
|
switch_size_t retsize;
|
||||||
char cmd[5] = "";
|
char dtmf[5] = "";
|
||||||
|
|
||||||
switch_time_exp_lt(&tm, switch_time_now());
|
switch_time_exp_lt(&tm, switch_time_now());
|
||||||
switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
|
switch_strftime(date, &retsize, sizeof(date), "%I:%M %p", &tm);
|
||||||
@ -501,14 +492,14 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
|
",<break time=\"500ms\"/>%s. %s. %s. local time: %s, Press 0 for options, 5 to change voice, or pound to return to the main menu. ",
|
||||||
title_txt, description_txt, rights_txt, date);
|
title_txt, description_txt, rights_txt, date);
|
||||||
args.input_callback = NULL;
|
args.input_callback = NULL;
|
||||||
args.buf = cmd;
|
args.buf = dtmf;
|
||||||
args.buflen = sizeof(cmd);
|
args.buflen = sizeof(dtmf);
|
||||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
||||||
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
|
||||||
goto finished;
|
goto finished;
|
||||||
}
|
}
|
||||||
if (*cmd != '\0') {
|
if (*dtmf != '\0') {
|
||||||
switch (*cmd) {
|
switch (*dtmf) {
|
||||||
case '0':
|
case '0':
|
||||||
switch_set_flag(&dtb, SFLAG_INSTRUCT);
|
switch_set_flag(&dtb, SFLAG_INSTRUCT);
|
||||||
break;
|
break;
|
||||||
@ -546,8 +537,8 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (switch_channel_ready(channel)) {
|
if (switch_channel_ready(channel)) {
|
||||||
char buf[1024] = "";
|
char tmpbuf[1024] = "";
|
||||||
uint32_t len = 0;
|
uint32_t tmplen = 0;
|
||||||
|
|
||||||
if (switch_test_flag(&dtb, SFLAG_MAIN)) {
|
if (switch_test_flag(&dtb, SFLAG_MAIN)) {
|
||||||
switch_clear_flag(&dtb, SFLAG_MAIN);
|
switch_clear_flag(&dtb, SFLAG_MAIN);
|
||||||
@ -555,14 +546,14 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
}
|
}
|
||||||
if (switch_test_flag(&dtb, SFLAG_INFO)) {
|
if (switch_test_flag(&dtb, SFLAG_INFO)) {
|
||||||
switch_clear_flag(&dtb, SFLAG_INFO);
|
switch_clear_flag(&dtb, SFLAG_INFO);
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s %s. I am speaking at %u words per minute. ", sh.engine, sh.voice, dtb.speed);
|
||||||
len = (uint32_t) strlen(buf);
|
tmplen = (uint32_t) strlen(tmpbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_test_flag(&dtb, SFLAG_INSTRUCT)) {
|
if (switch_test_flag(&dtb, SFLAG_INSTRUCT)) {
|
||||||
switch_clear_flag(&dtb, SFLAG_INSTRUCT);
|
switch_clear_flag(&dtb, SFLAG_INSTRUCT);
|
||||||
cont = 1;
|
cont = 1;
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len,
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s",
|
||||||
"Press star to pause or resume speech. "
|
"Press star to pause or resume speech. "
|
||||||
"To go to the next item, press six. "
|
"To go to the next item, press six. "
|
||||||
"To go back, press 4. "
|
"To go back, press 4. "
|
||||||
@ -570,29 +561,29 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
"To change voices, press five. To restore the original voice press 9. "
|
"To change voices, press five. To restore the original voice press 9. "
|
||||||
"To hear these options again, press zero or press pound to return to the main menu. ");
|
"To hear these options again, press zero or press pound to return to the main menu. ");
|
||||||
} else {
|
} else {
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "Story %d. ", dtb.index + 1);
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "Story %d. ", dtb.index + 1);
|
||||||
len = (uint32_t) strlen(buf);
|
tmplen = (uint32_t) strlen(tmpbuf);
|
||||||
|
|
||||||
if (entries[dtb.index].subject_txt) {
|
if (entries[dtb.index].subject_txt) {
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "Subject: %s. ", entries[dtb.index].subject_txt);
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "Subject: %s. ", entries[dtb.index].subject_txt);
|
||||||
len = (uint32_t) strlen(buf);
|
tmplen = (uint32_t) strlen(tmpbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries[dtb.index].dept_txt) {
|
if (entries[dtb.index].dept_txt) {
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "From the %s department. ", entries[dtb.index].dept_txt);
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "From the %s department. ", entries[dtb.index].dept_txt);
|
||||||
len = (uint32_t) strlen(buf);
|
tmplen = (uint32_t) strlen(tmpbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entries[dtb.index].title_txt) {
|
if (entries[dtb.index].title_txt) {
|
||||||
switch_snprintf(buf + len, sizeof(buf) - len, "%s", entries[dtb.index].title_txt);
|
switch_snprintf(tmpbuf + tmplen, sizeof(tmpbuf) - tmplen, "%s", entries[dtb.index].title_txt);
|
||||||
len = (uint32_t) strlen(buf);
|
tmplen = (uint32_t) strlen(tmpbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_core_speech_flush_tts(&sh);
|
switch_core_speech_flush_tts(&sh);
|
||||||
args.input_callback = on_dtmf;
|
args.input_callback = on_dtmf;
|
||||||
args.buf = &dtb;
|
args.buf = &dtb;
|
||||||
args.buflen = sizeof(dtb);
|
args.buflen = sizeof(dtb);
|
||||||
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, buf, &args);
|
status = switch_ivr_speak_text_handle(session, &sh, &speech_codec, timerp, tmpbuf, &args);
|
||||||
if (status == SWITCH_STATUS_BREAK) {
|
if (status == SWITCH_STATUS_BREAK) {
|
||||||
continue;
|
continue;
|
||||||
} else if (status != SWITCH_STATUS_SUCCESS) {
|
} else if (status != SWITCH_STATUS_SUCCESS) {
|
||||||
@ -632,9 +623,7 @@ SWITCH_STANDARD_APP(rss_function)
|
|||||||
switch_core_timer_destroy(&timer);
|
switch_core_timer_destroy(&timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_xml_free(xml);
|
switch_xml_free(xml);
|
||||||
|
|
||||||
switch_core_session_reset(session);
|
switch_core_session_reset(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user