app_image.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 transmit an image
  21. *
  22. * \author Mark Spencer <markster@digium.com>
  23. *
  24. * \ingroup applications
  25. */
  26. /*** MODULEINFO
  27. <support_level>extended</support_level>
  28. ***/
  29. #include "asterisk.h"
  30. ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
  31. #include "asterisk/pbx.h"
  32. #include "asterisk/module.h"
  33. #include "asterisk/image.h"
  34. static char *app = "SendImage";
  35. /*** DOCUMENTATION
  36. <application name="SendImage" language="en_US">
  37. <synopsis>
  38. Sends an image file.
  39. </synopsis>
  40. <syntax>
  41. <parameter name="filename" required="true">
  42. <para>Path of the filename (image) to send.</para>
  43. </parameter>
  44. </syntax>
  45. <description>
  46. <para>Send an image file on a channel supporting it.</para>
  47. <para>Result of transmission will be stored in <variable>SENDIMAGESTATUS</variable></para>
  48. <variablelist>
  49. <variable name="SENDIMAGESTATUS">
  50. <value name="SUCCESS">
  51. Transmission succeeded.
  52. </value>
  53. <value name="FAILURE">
  54. Transmission failed.
  55. </value>
  56. <value name="UNSUPPORTED">
  57. Image transmission not supported by channel.
  58. </value>
  59. </variable>
  60. </variablelist>
  61. </description>
  62. <see-also>
  63. <ref type="application">SendText</ref>
  64. <ref type="application">SendURL</ref>
  65. </see-also>
  66. </application>
  67. ***/
  68. static int sendimage_exec(struct ast_channel *chan, const char *data)
  69. {
  70. if (ast_strlen_zero(data)) {
  71. ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
  72. return -1;
  73. }
  74. if (!ast_supports_images(chan)) {
  75. /* Does not support transport */
  76. pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED");
  77. return 0;
  78. }
  79. if (!ast_send_image(chan, data)) {
  80. pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS");
  81. } else {
  82. pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE");
  83. }
  84. return 0;
  85. }
  86. static int unload_module(void)
  87. {
  88. return ast_unregister_application(app);
  89. }
  90. static int load_module(void)
  91. {
  92. return ast_register_application_xml(app, sendimage_exec);
  93. }
  94. AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Image Transmission Application");