| 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 |
#include "asterisk.h" |
| 29 |
|
| 30 |
#include "asterisk/module.h" |
| 31 |
#include "asterisk/channel.h" |
| 32 |
#include "asterisk/ccss.h" |
| 33 |
#include "asterisk/pbx.h" |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 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 |
static int acf_cc_read(struct ast_channel *chan, const char *name, char *data, |
| 72 |
char *buf, size_t buf_len) |
| 73 |
{ |
| 74 |
struct ast_cc_config_params *cc_params; |
| 75 |
int res; |
| 76 |
|
| 77 |
if (!chan) { |
| 78 |
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name); |
| 79 |
return -1; |
| 80 |
} |
| 81 |
|
| 82 |
ast_channel_lock(chan); |
| 83 |
if (!(cc_params = ast_channel_get_cc_config_params(chan))) { |
| 84 |
ast_channel_unlock(chan); |
| 85 |
return -1; |
| 86 |
} |
| 87 |
|
| 88 |
res = ast_cc_get_param(cc_params, data, buf, buf_len); |
| 89 |
ast_channel_unlock(chan); |
| 90 |
return res; |
| 91 |
} |
| 92 |
|
| 93 |
static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data, |
| 94 |
const char *value) |
| 95 |
{ |
| 96 |
struct ast_cc_config_params *cc_params; |
| 97 |
int res; |
| 98 |
|
| 99 |
if (!chan) { |
| 100 |
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd); |
| 101 |
return -1; |
| 102 |
} |
| 103 |
|
| 104 |
ast_channel_lock(chan); |
| 105 |
if (!(cc_params = ast_channel_get_cc_config_params(chan))) { |
| 106 |
ast_channel_unlock(chan); |
| 107 |
return -1; |
| 108 |
} |
| 109 |
|
| 110 |
res = ast_cc_set_param(cc_params, data, value); |
| 111 |
ast_channel_unlock(chan); |
| 112 |
return res; |
| 113 |
} |
| 114 |
|
| 115 |
static struct ast_custom_function cc_function = { |
| 116 |
.name = "CALLCOMPLETION", |
| 117 |
.read = acf_cc_read, |
| 118 |
.write = acf_cc_write, |
| 119 |
}; |
| 120 |
|
| 121 |
static int unload_module(void) |
| 122 |
{ |
| 123 |
return ast_custom_function_unregister(&cc_function); |
| 124 |
} |
| 125 |
|
| 126 |
static int load_module(void) |
| 127 |
{ |
| 128 |
return ast_custom_function_register(&cc_function) == 0 ? AST_MODULE_LOAD_SUCCESS : AST_MODULE_LOAD_DECLINE; |
| 129 |
} |
| 130 |
|
| 131 |
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Call Control Configuration Function", |
| 132 |
.support_level = AST_MODULE_SUPPORT_CORE, |
| 133 |
.load = load_module, |
| 134 |
.unload = unload_module, |
| 135 |
.requires = "ccss", |
| 136 |
); |