app_setcallerid.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include "asterisk.h"
  27. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  28. #include "asterisk/lock.h"
  29. #include "asterisk/file.h"
  30. #include "asterisk/channel.h"
  31. #include "asterisk/pbx.h"
  32. #include "asterisk/module.h"
  33. #include "asterisk/translate.h"
  34. #include "asterisk/image.h"
  35. #include "asterisk/callerid.h"
  36. static char *app2 = "SetCallerPres";
  37. static char *synopsis2 = "Set CallerID Presentation";
  38. static char *descrip2 =
  39. " SetCallerPres(presentation): Set Caller*ID presentation on a call.\n"
  40. " Valid presentations are:\n"
  41. "\n"
  42. " allowed_not_screened : Presentation Allowed, Not Screened\n"
  43. " allowed_passed_screen : Presentation Allowed, Passed Screen\n"
  44. " allowed_failed_screen : Presentation Allowed, Failed Screen\n"
  45. " allowed : Presentation Allowed, Network Number\n"
  46. " prohib_not_screened : Presentation Prohibited, Not Screened\n"
  47. " prohib_passed_screen : Presentation Prohibited, Passed Screen\n"
  48. " prohib_failed_screen : Presentation Prohibited, Failed Screen\n"
  49. " prohib : Presentation Prohibited, Network Number\n"
  50. " unavailable : Number Unavailable\n"
  51. "\n"
  52. ;
  53. static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
  54. {
  55. int pres = -1;
  56. static int deprecated = 0;
  57. if (!deprecated) {
  58. deprecated = 1;
  59. ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
  60. }
  61. /* For interface consistency, permit the argument to be specified as a number */
  62. if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
  63. pres = ast_parse_caller_presentation(data);
  64. }
  65. if (pres < 0) {
  66. ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
  67. (char *) data);
  68. return 0;
  69. }
  70. chan->cid.cid_pres = pres;
  71. return 0;
  72. }
  73. static int unload_module(void)
  74. {
  75. return ast_unregister_application(app2);
  76. }
  77. static int load_module(void)
  78. {
  79. return ast_register_application(app2, setcallerid_pres_exec, synopsis2, descrip2);
  80. }
  81. AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");