git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6997 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming 2005-11-07 22:55:34 +00:00
parent 1ca8bccc2f
commit 8f536c775e
2 changed files with 32 additions and 10 deletions

View File

@ -1,5 +1,7 @@
2005-11-07 Kevin P. Fleming <kpfleming@digium.com> 2005-11-07 Kevin P. Fleming <kpfleming@digium.com>
* apps/app_sendtext.c: upgrade to new arg/option API and implement priority jumping control
* apps/app_transfer.c: upgrade to new arg/option API and implement priority jumping control * apps/app_transfer.c: upgrade to new arg/option API and implement priority jumping control
* apps/app_txtcidname.c: upgrade to new arg/option API and implement priority jumping control * apps/app_txtcidname.c: upgrade to new arg/option API and implement priority jumping control

View File

@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h" #include "asterisk/translate.h"
#include "asterisk/image.h" #include "asterisk/image.h"
#include "asterisk/options.h" #include "asterisk/options.h"
#include "asterisk/app.h"
static const char *tdesc = "Send Text Applications"; static const char *tdesc = "Send Text Applications";
@ -49,8 +50,7 @@ static const char *app = "SendText";
static const char *synopsis = "Send a Text Message"; static const char *synopsis = "Send a Text Message";
static const char *descrip = static const char *descrip =
" SendText(text): Sends text to current channel (callee).\n" " SendText(text[|options]): Sends text to current channel (callee).\n"
"Otherwise, execution will continue at the next priority level.\n"
"Result of transmission will be stored in the SENDTEXTSTATUS\n" "Result of transmission will be stored in the SENDTEXTSTATUS\n"
"channel variable:\n" "channel variable:\n"
" SUCCESS Transmission succeeded\n" " SUCCESS Transmission succeeded\n"
@ -58,10 +58,9 @@ static const char *descrip =
" UNSUPPORTED Text transmission not supported by channel\n" " UNSUPPORTED Text transmission not supported by channel\n"
"\n" "\n"
"At this moment, text is supposed to be 7 bit ASCII in most channels.\n" "At this moment, text is supposed to be 7 bit ASCII in most channels.\n"
"Old deprecated behavior: \n" "The option string many contain the following character:\n"
" SendText should continue with the next priority upon successful execution.\n" "'j' -- jump to n+101 priority if the channel doesn't support\n"
" If the client does not support text transport, and there exists a\n" " text transport\n";
" step with priority n + 101, then execution will continue at that step.\n";
STANDARD_LOCAL_USER; STANDARD_LOCAL_USER;
@ -72,26 +71,47 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
int res = 0; int res = 0;
struct localuser *u; struct localuser *u;
char *status = "UNSUPPORTED"; char *status = "UNSUPPORTED";
char *parse = NULL;
int priority_jump = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(text);
AST_APP_ARG(options);
);
LOCAL_USER_ADD(u);
if (ast_strlen_zero(data)) { if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SendText requires an argument (text)\n"); ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
LOCAL_USER_REMOVE(u);
return -1; return -1;
} else {
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
} }
LOCAL_USER_ADD(u); AST_STANDARD_APP_ARGS(args, parse);
if (args.options) {
if (strchr(args.options, 'j'))
priority_jump = 1;
}
ast_mutex_lock(&chan->lock); ast_mutex_lock(&chan->lock);
if (!chan->tech->send_text) { if (!chan->tech->send_text) {
ast_mutex_unlock(&chan->lock); ast_mutex_unlock(&chan->lock);
/* Does not support transport */ /* Does not support transport */
if (option_priority_jumping) if (priority_jump || option_priority_jumping)
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return 0; return 0;
} }
status = "FAILURE"; status = "FAILURE";
ast_mutex_unlock(&chan->lock); ast_mutex_unlock(&chan->lock);
res = ast_sendtext(chan, (char *)data); res = ast_sendtext(chan, args.text);
if (!res) if (!res)
status = "SUCCESS"; status = "SUCCESS";
pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status); pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);