2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief App to set callerid
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/translate.h"
43 #include "asterisk/image.h"
44 #include "asterisk/callerid.h"
46 static char *app2
= "SetCallerPres";
48 static char *synopsis2
= "Set CallerID Presentation";
51 static char *descrip2
=
52 " SetCallerPres(presentation): Set Caller*ID presentation on a call.\n"
53 " Valid presentations are:\n"
55 " allowed_not_screened : Presentation Allowed, Not Screened\n"
56 " allowed_passed_screen : Presentation Allowed, Passed Screen\n"
57 " allowed_failed_screen : Presentation Allowed, Failed Screen\n"
58 " allowed : Presentation Allowed, Network Number\n"
59 " prohib_not_screened : Presentation Prohibited, Not Screened\n"
60 " prohib_passed_screen : Presentation Prohibited, Passed Screen\n"
61 " prohib_failed_screen : Presentation Prohibited, Failed Screen\n"
62 " prohib : Presentation Prohibited, Network Number\n"
63 " unavailable : Number Unavailable\n"
67 static int setcallerid_pres_exec(struct ast_channel
*chan
, void *data
)
69 struct ast_module_user
*u
;
72 u
= ast_module_user_add(chan
);
74 /* For interface consistency, permit the argument to be specified as a number */
75 if (sscanf(data
, "%d", &pres
) != 1 || pres
< 0 || pres
> 255 || (pres
& 0x9c)) {
76 pres
= ast_parse_caller_presentation(data
);
80 ast_log(LOG_WARNING
, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
82 ast_module_user_remove(u
);
86 chan
->cid
.cid_pres
= pres
;
87 ast_module_user_remove(u
);
91 static char *app
= "SetCallerID";
93 static char *synopsis
= "Set CallerID";
95 static char *descrip
=
96 " SetCallerID(clid[|a]): Set Caller*ID on a call to a new\n"
97 "value. Sets ANI as well if a flag is used. \n";
99 static int setcallerid_exec(struct ast_channel
*chan
, void *data
)
105 struct ast_module_user
*u
;
108 static int dep_warning
= 0;
110 if (ast_strlen_zero(data
)) {
111 ast_log(LOG_WARNING
, "SetCallerID requires an argument!\n");
115 u
= ast_module_user_add(chan
);
119 ast_log(LOG_WARNING
, "SetCallerID is deprecated. Please use Set(CALLERID(all)=...) or Set(CALLERID(ani)=...) instead.\n");
122 tmp
= ast_strdupa(data
);
124 opt
= strchr(tmp
, '|');
132 ast_callerid_split(tmp
, name
, sizeof(name
), num
, sizeof(num
));
133 ast_set_callerid(chan
, num
, name
, anitoo
? num
: NULL
);
135 ast_module_user_remove(u
);
140 static int unload_module(void)
144 res
= ast_unregister_application(app2
);
145 res
|= ast_unregister_application(app
);
147 ast_module_user_hangup_all();
152 static int load_module(void)
156 res
= ast_register_application(app2
, setcallerid_pres_exec
, synopsis2
, descrip2
);
157 res
|= ast_register_application(app
, setcallerid_exec
, synopsis
, descrip
);
162 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Set CallerID Application");