| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include "asterisk.h" |
| 33 |
|
| 34 |
#include "asterisk/pbx.h" |
| 35 |
#include "asterisk/module.h" |
| 36 |
#include "asterisk/app.h" |
| 37 |
#include "asterisk/channel.h" |
| 38 |
#include "asterisk/bridge.h" |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
static const char * const app = "BlindTransfer"; |
| 84 |
|
| 85 |
static int blind_transfer_exec(struct ast_channel *chan, const char *data) |
| 86 |
{ |
| 87 |
char *exten = NULL; |
| 88 |
char *context = NULL; |
| 89 |
char *parse; |
| 90 |
AST_DECLARE_APP_ARGS(args, |
| 91 |
AST_APP_ARG(exten); |
| 92 |
AST_APP_ARG(context); |
| 93 |
); |
| 94 |
|
| 95 |
if (ast_strlen_zero((char *)data)) { |
| 96 |
ast_log(LOG_WARNING, "%s requires an argument (exten)\n", app); |
| 97 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "FAILURE"); |
| 98 |
return 0; |
| 99 |
} |
| 100 |
|
| 101 |
parse = ast_strdupa(data); |
| 102 |
AST_STANDARD_APP_ARGS(args, parse); |
| 103 |
|
| 104 |
exten = args.exten; |
| 105 |
if (ast_strlen_zero(args.context)) { |
| 106 |
context = (char *)ast_channel_context(chan); |
| 107 |
} else { |
| 108 |
context = args.context; |
| 109 |
} |
| 110 |
|
| 111 |
switch (ast_bridge_transfer_blind(1, chan, exten, context, NULL, NULL)) { |
| 112 |
case AST_BRIDGE_TRANSFER_NOT_PERMITTED: |
| 113 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "NOTPERMITTED"); |
| 114 |
break; |
| 115 |
case AST_BRIDGE_TRANSFER_INVALID: |
| 116 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "INVALID"); |
| 117 |
break; |
| 118 |
case AST_BRIDGE_TRANSFER_FAIL: |
| 119 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "FAILURE"); |
| 120 |
break; |
| 121 |
case AST_BRIDGE_TRANSFER_SUCCESS: |
| 122 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "SUCCESS"); |
| 123 |
break; |
| 124 |
default: |
| 125 |
pbx_builtin_setvar_helper(chan, "BLINDTRANSFERSTATUS", "FAILURE"); |
| 126 |
} |
| 127 |
|
| 128 |
return 0; |
| 129 |
} |
| 130 |
|
| 131 |
static int unload_module(void) |
| 132 |
{ |
| 133 |
return ast_unregister_application(app); |
| 134 |
} |
| 135 |
|
| 136 |
static int load_module(void) |
| 137 |
{ |
| 138 |
return ast_register_application_xml(app, blind_transfer_exec); |
| 139 |
} |
| 140 |
|
| 141 |
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Blind transfer channel to the given destination"); |