app_setcallerid.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief App to set callerid presentation
00022  *
00023  * \author Mark Spencer <markster@digium.com>
00024  * 
00025  * \ingroup applications
00026  */
00027 
00028 /*** MODULEINFO
00029    <defaultenabled>no</defaultenabled>
00030    <support_level>deprecated</support_level>
00031    <replacement>func_callerid</replacement>
00032  ***/
00033 
00034 #include "asterisk.h"
00035 
00036 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419592 $")
00037 
00038 #include "asterisk/lock.h"
00039 #include "asterisk/file.h"
00040 #include "asterisk/channel.h"
00041 #include "asterisk/pbx.h"
00042 #include "asterisk/module.h"
00043 #include "asterisk/translate.h"
00044 #include "asterisk/image.h"
00045 #include "asterisk/callerid.h"
00046 
00047 /*** DOCUMENTATION
00048    <application name="SetCallerPres" language="en_US">
00049       <synopsis>
00050          Set CallerID Presentation.
00051       </synopsis>
00052       <syntax>
00053          <parameter name="presentation" required="true">
00054             <enumlist>
00055                <enum name="allowed_not_screened">
00056                   <para>Presentation Allowed, Not Screened.</para>
00057                </enum>
00058                <enum name="allowed_passed_screen">
00059                   <para>Presentation Allowed, Passed Screen.</para>
00060                </enum>
00061                <enum name="allowed_failed_screen">
00062                   <para>Presentation Allowed, Failed Screen.</para>
00063                </enum>
00064                <enum name="allowed">
00065                   <para>Presentation Allowed, Network Number.</para>
00066                </enum>
00067                <enum name="prohib_not_screened">
00068                   <para>Presentation Prohibited, Not Screened.</para>
00069                </enum>
00070                <enum name="prohib_passed_screen">
00071                   <para>Presentation Prohibited, Passed Screen.</para>
00072                </enum>
00073                <enum name="prohib_failed_screen">
00074                   <para>Presentation Prohibited, Failed Screen.</para>
00075                </enum>
00076                <enum name="prohib">
00077                   <para>Presentation Prohibited, Network Number.</para>
00078                </enum>
00079                <enum name="unavailable">
00080                   <para>Number Unavailable.</para>
00081                </enum>
00082             </enumlist>
00083          </parameter>
00084       </syntax>
00085       <description>
00086          <para>Set Caller*ID presentation on a call.</para>
00087       </description>
00088    </application>
00089  ***/
00090 
00091 static char *app2 = "SetCallerPres";
00092 
00093 static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
00094 {
00095    int pres = -1;
00096    static int deprecated = 0;
00097 
00098    if (!deprecated) {
00099       deprecated = 1;
00100       ast_log(LOG_WARNING, "SetCallerPres is deprecated.  Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
00101    }
00102 
00103    /* For interface consistency, permit the argument to be specified as a number */
00104    if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
00105       pres = ast_parse_caller_presentation(data);
00106    }
00107 
00108    if (pres < 0) {
00109       ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
00110          (char *) data);
00111       return 0;
00112    }
00113    
00114    /* Set the combined caller id presentation. */
00115    ast_channel_caller(chan)->id.name.presentation = pres;
00116    ast_channel_caller(chan)->id.number.presentation = pres;
00117    return 0;
00118 }
00119 
00120 static int unload_module(void)
00121 {
00122    return ast_unregister_application(app2);
00123 }
00124 
00125 static int load_module(void)
00126 {
00127    return ast_register_application_xml(app2, setcallerid_pres_exec);
00128 }
00129 
00130 AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");
00131 

Generated on Thu Apr 16 06:27:12 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6