00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "asterisk.h"
00031
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328209 $")
00033
00034 #include "asterisk/file.h"
00035 #include "asterisk/channel.h"
00036 #include "asterisk/pbx.h"
00037 #include "asterisk/module.h"
00038 #include "asterisk/lock.h"
00039 #include "asterisk/app.h"
00040 #include "asterisk/features.h"
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 static const char app[] = "ChannelRedirect";
00068
00069 static int asyncgoto_exec(struct ast_channel *chan, const char *data)
00070 {
00071 int res = -1;
00072 char *info;
00073 struct ast_channel *chan2 = NULL;
00074
00075 AST_DECLARE_APP_ARGS(args,
00076 AST_APP_ARG(channel);
00077 AST_APP_ARG(label);
00078 );
00079
00080 if (ast_strlen_zero(data)) {
00081 ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
00082 return -1;
00083 }
00084
00085 info = ast_strdupa(data);
00086 AST_STANDARD_APP_ARGS(args, info);
00087
00088 if (ast_strlen_zero(args.channel) || ast_strlen_zero(args.label)) {
00089 ast_log(LOG_WARNING, "%s requires an argument (channel,[[context,]exten,]priority)\n", app);
00090 return -1;
00091 }
00092
00093 if (!(chan2 = ast_channel_get_by_name(args.channel))) {
00094 ast_log(LOG_WARNING, "No such channel: %s\n", args.channel);
00095 pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "NOCHANNEL");
00096 return 0;
00097 }
00098
00099 if (chan2->pbx) {
00100 ast_set_flag(chan2, AST_FLAG_BRIDGE_HANGUP_DONT);
00101 }
00102
00103 res = ast_async_parseable_goto(chan2, args.label);
00104
00105 chan2 = ast_channel_unref(chan2);
00106
00107 pbx_builtin_setvar_helper(chan, "CHANNELREDIRECT_STATUS", "SUCCESS");
00108
00109 return res;
00110 }
00111
00112 static int unload_module(void)
00113 {
00114 return ast_unregister_application(app);
00115 }
00116
00117 static int load_module(void)
00118 {
00119 return ast_register_application_xml(app, asyncgoto_exec) ?
00120 AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
00121 }
00122
00123 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Redirects a given channel to a dialplan target");