Thu Apr 28 2011 17:15:15

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