Tue Aug 20 16:34:22 2013

Asterisk developer's documentation


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    <support_level>deprecated</support_level>
00030    <replacement>func_callerid</replacement>
00031  ***/
00032 
00033 #include "asterisk.h"
00034 
00035 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328446 $")
00036 
00037 #include "asterisk/lock.h"
00038 #include "asterisk/file.h"
00039 #include "asterisk/channel.h"
00040 #include "asterisk/pbx.h"
00041 #include "asterisk/module.h"
00042 #include "asterisk/translate.h"
00043 #include "asterisk/image.h"
00044 #include "asterisk/callerid.h"
00045 
00046 /*** DOCUMENTATION
00047    <application name="SetCallerPres" language="en_US">
00048       <synopsis>
00049          Set CallerID Presentation.
00050       </synopsis>
00051       <syntax>
00052          <parameter name="presentation" required="true">
00053             <enumlist>
00054                <enum name="allowed_not_screened">
00055                   <para>Presentation Allowed, Not Screened.</para>
00056                </enum>
00057                <enum name="allowed_passed_screen">
00058                   <para>Presentation Allowed, Passed Screen.</para>
00059                </enum>
00060                <enum name="allowed_failed_screen">
00061                   <para>Presentation Allowed, Failed Screen.</para>
00062                </enum>
00063                <enum name="allowed">
00064                   <para>Presentation Allowed, Network Number.</para>
00065                </enum>
00066                <enum name="prohib_not_screened">
00067                   <para>Presentation Prohibited, Not Screened.</para>
00068                </enum>
00069                <enum name="prohib_passed_screen">
00070                   <para>Presentation Prohibited, Passed Screen.</para>
00071                </enum>
00072                <enum name="prohib_failed_screen">
00073                   <para>Presentation Prohibited, Failed Screen.</para>
00074                </enum>
00075                <enum name="prohib">
00076                   <para>Presentation Prohibited, Network Number.</para>
00077                </enum>
00078                <enum name="unavailable">
00079                   <para>Number Unavailable.</para>
00080                </enum>
00081             </enumlist>
00082          </parameter>
00083       </syntax>
00084       <description>
00085          <para>Set Caller*ID presentation on a call.</para>
00086       </description>
00087    </application>
00088  ***/
00089 
00090 static char *app2 = "SetCallerPres";
00091 
00092 static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
00093 {
00094    int pres = -1;
00095    static int deprecated = 0;
00096 
00097    if (!deprecated) {
00098       deprecated = 1;
00099       ast_log(LOG_WARNING, "SetCallerPres is deprecated.  Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
00100    }
00101 
00102    /* For interface consistency, permit the argument to be specified as a number */
00103    if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
00104       pres = ast_parse_caller_presentation(data);
00105    }
00106 
00107    if (pres < 0) {
00108       ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
00109          (char *) data);
00110       return 0;
00111    }
00112    
00113    /* Set the combined caller id presentation. */
00114    chan->caller.id.name.presentation = pres;
00115    chan->caller.id.number.presentation = pres;
00116    return 0;
00117 }
00118 
00119 static int unload_module(void)
00120 {
00121    return ast_unregister_application(app2);
00122 }
00123 
00124 static int load_module(void)
00125 {
00126    return ast_register_application_xml(app2, setcallerid_pres_exec);
00127 }
00128 
00129 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");

Generated on 20 Aug 2013 for Asterisk - The Open Source Telephony Project by  doxygen 1.6.1