app_setcallerid.c 3.5 KB

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