git migration: Refactor the ASTERISK_FILE_VERSION macro
[asterisk/asterisk.git] / apps / app_setcallerid.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
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.
13  *
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.
17  */
18
19 /*! \file
20  *
21  * \brief App to set callerid presentation
22  *
23  * \author Mark Spencer <markster@digium.com>
24  * 
25  * \ingroup applications
26  */
27
28 /*** MODULEINFO
29         <defaultenabled>no</defaultenabled>
30         <support_level>deprecated</support_level>
31         <replacement>func_callerid</replacement>
32  ***/
33
34 #include "asterisk.h"
35
36 ASTERISK_REGISTER_FILE()
37
38 #include "asterisk/lock.h"
39 #include "asterisk/file.h"
40 #include "asterisk/channel.h"
41 #include "asterisk/pbx.h"
42 #include "asterisk/module.h"
43 #include "asterisk/translate.h"
44 #include "asterisk/image.h"
45 #include "asterisk/callerid.h"
46
47 /*** DOCUMENTATION
48         <application name="SetCallerPres" language="en_US">
49                 <synopsis>
50                         Set CallerID Presentation.
51                 </synopsis>
52                 <syntax>
53                         <parameter name="presentation" required="true">
54                                 <enumlist>
55                                         <enum name="allowed_not_screened">
56                                                 <para>Presentation Allowed, Not Screened.</para>
57                                         </enum>
58                                         <enum name="allowed_passed_screen">
59                                                 <para>Presentation Allowed, Passed Screen.</para>
60                                         </enum>
61                                         <enum name="allowed_failed_screen">
62                                                 <para>Presentation Allowed, Failed Screen.</para>
63                                         </enum>
64                                         <enum name="allowed">
65                                                 <para>Presentation Allowed, Network Number.</para>
66                                         </enum>
67                                         <enum name="prohib_not_screened">
68                                                 <para>Presentation Prohibited, Not Screened.</para>
69                                         </enum>
70                                         <enum name="prohib_passed_screen">
71                                                 <para>Presentation Prohibited, Passed Screen.</para>
72                                         </enum>
73                                         <enum name="prohib_failed_screen">
74                                                 <para>Presentation Prohibited, Failed Screen.</para>
75                                         </enum>
76                                         <enum name="prohib">
77                                                 <para>Presentation Prohibited, Network Number.</para>
78                                         </enum>
79                                         <enum name="unavailable">
80                                                 <para>Number Unavailable.</para>
81                                         </enum>
82                                 </enumlist>
83                         </parameter>
84                 </syntax>
85                 <description>
86                         <para>Set Caller*ID presentation on a call.</para>
87                 </description>
88         </application>
89  ***/
90
91 static char *app2 = "SetCallerPres";
92
93 static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
94 {
95         int pres = -1;
96         static int deprecated = 0;
97
98         if (!deprecated) {
99                 deprecated = 1;
100                 ast_log(LOG_WARNING, "SetCallerPres is deprecated.  Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
101         }
102
103         /* For interface consistency, permit the argument to be specified as a number */
104         if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
105                 pres = ast_parse_caller_presentation(data);
106         }
107
108         if (pres < 0) {
109                 ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
110                         (char *) data);
111                 return 0;
112         }
113         
114         /* Set the combined caller id presentation. */
115         ast_channel_caller(chan)->id.name.presentation = pres;
116         ast_channel_caller(chan)->id.number.presentation = pres;
117         return 0;
118 }
119
120 static int unload_module(void)
121 {
122         return ast_unregister_application(app2);
123 }
124
125 static int load_module(void)
126 {
127         return ast_register_application_xml(app2, setcallerid_pres_exec);
128 }
129
130 AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");
131