19
19
#include <asterisk/module.h>
20
20
#include <asterisk/translate.h>
21
21
#include <asterisk/image.h>
22
#include <asterisk/callerid.h>
22
23
#include <string.h>
23
24
#include <stdlib.h>
26
static char *app2 = "SetCallerPres";
28
static char *synopsis2 = "Set CallerID Presentation";
38
{ AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, "allowed_not_screened" },
39
{ AST_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, "allowed_passed_screen" },
40
{ AST_PRES_ALLOWED_USER_NUMBER_FAILED_SCREEN, "allowed_failed_screen" },
41
{ AST_PRES_ALLOWED_NETWORK_NUMBER, "allowed" },
42
{ AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED , "prohib_not_screened" },
43
{ AST_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN, "prohib_passed_screen" },
44
{ AST_PRES_PROHIB_USER_NUMBER_FAILED_SCREEN, "prohib_failed_screen" },
45
{ AST_PRES_PROHIB_NETWORK_NUMBER, "prohib" },
46
{ AST_PRES_NUMBER_NOT_AVAILABLE, "unavailable" },
49
static char *descrip2 =
50
" SetCallerPres(presentation): Set Caller*ID presentation on\n"
51
"a call to a new value. Sets ANI as well if a flag is used.\n"
52
"Always returns 0. Valid presentations are:\n"
54
" allowed_not_screened : Presentation Allowed, Not Screened\n"
55
" allowed_passed_screen : Presentation Allowed, Passed Screen\n"
56
" allowed_failed_screen : Presentation Allowed, Failed Screen\n"
57
" allowed : Presentation Allowed, Network Number\n"
58
" prohib_not_screened : Presentation Prohibited, Not Screened\n"
59
" prohib_passed_screen : Presentation Prohibited, Passed Screen\n"
60
" prohib_failed_screen : Presentation Prohibited, Failed Screen\n"
61
" prohib : Presentation Prohibited, Network Number\n"
62
" unavailable : Number Unavailable\n"
66
static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
75
strncpy(tmp, (char *)data, sizeof(tmp) - 1);
76
opts = strchr(tmp, '|');
81
for (x=0;x<sizeof(preses) / sizeof(preses[0]);x++) {
82
if (!strcasecmp(preses[x].name, tmp)) {
88
ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n", tmp);
92
chan->callingpres = pres;
26
99
static char *tdesc = "Set CallerID Application";
62
131
int unload_module(void)
64
133
STANDARD_HANGUP_LOCALUSERS;
134
ast_unregister_application(app2);
65
135
return ast_unregister_application(app);
68
138
int load_module(void)
140
ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2);
70
141
return ast_register_application(app, setcallerid_exec, synopsis, descrip);