app_image.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Asterisk -- A telephony toolkit for Linux.
  3. *
  4. * App to transmit an image
  5. *
  6. * Copyright (C) 1999, Mark Spencer
  7. *
  8. * Mark Spencer <markster@linux-support.net>
  9. *
  10. * This program is free software, distributed under the terms of
  11. * the GNU General Public License
  12. */
  13. #include <asterisk/lock.h>
  14. #include <asterisk/file.h>
  15. #include <asterisk/logger.h>
  16. #include <asterisk/channel.h>
  17. #include <asterisk/pbx.h>
  18. #include <asterisk/module.h>
  19. #include <asterisk/translate.h>
  20. #include <asterisk/image.h>
  21. #include <string.h>
  22. #include <stdlib.h>
  23. static char *tdesc = "Image Transmission Application";
  24. static char *app = "SendImage";
  25. static char *synopsis = "Send an image file";
  26. static char *descrip =
  27. " SendImage(filename): Sends an image on a channel. If the channel\n"
  28. "does not support image transport, and there exists a step with\n"
  29. "priority n + 101, then execution will continue at that step.\n"
  30. "Otherwise, execution will continue at the next priority level.\n"
  31. "SendImage only returns 0 if the image was sent correctly or if\n"
  32. "the channel does not support image transport, and -1 otherwise.\n";
  33. STANDARD_LOCAL_USER;
  34. LOCAL_USER_DECL;
  35. static int sendimage_exec(struct ast_channel *chan, void *data)
  36. {
  37. int res = 0;
  38. struct localuser *u;
  39. if (!data || !strlen((char *)data)) {
  40. ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
  41. return -1;
  42. }
  43. LOCAL_USER_ADD(u);
  44. if (!ast_supports_images(chan)) {
  45. /* Does not support transport */
  46. if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
  47. chan->priority += 100;
  48. return 0;
  49. }
  50. res = ast_send_image(chan, data);
  51. LOCAL_USER_REMOVE(u);
  52. return res;
  53. }
  54. int unload_module(void)
  55. {
  56. STANDARD_HANGUP_LOCALUSERS;
  57. return ast_unregister_application(app);
  58. }
  59. int load_module(void)
  60. {
  61. return ast_register_application(app, sendimage_exec, synopsis, descrip);
  62. }
  63. char *description(void)
  64. {
  65. return tdesc;
  66. }
  67. int usecount(void)
  68. {
  69. int res;
  70. STANDARD_USECOUNT(res);
  71. return res;
  72. }
  73. char *key()
  74. {
  75. return ASTERISK_GPL_KEY;
  76. }