2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
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.
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.
21 * \brief App to transmit an image
23 * \ingroup applications
31 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
33 #include "asterisk/lock.h"
34 #include "asterisk/file.h"
35 #include "asterisk/logger.h"
36 #include "asterisk/channel.h"
37 #include "asterisk/pbx.h"
38 #include "asterisk/module.h"
39 #include "asterisk/translate.h"
40 #include "asterisk/image.h"
41 #include "asterisk/app.h"
42 #include "asterisk/options.h"
44 static char *tdesc = "Image Transmission Application";
46 static char *app = "SendImage";
48 static char *synopsis = "Send an image file";
50 static char *descrip =
51 " SendImage(filename): Sends an image on a channel. \n"
52 "SendImage only returns 0 if the image was sent correctly or if\n"
53 "the channel does not support image transport, and -1 otherwise.\n"
54 "The option string may contain zero or the following character:\n"
55 " 'j' -- jump to priority n+101 if the channel doesn't support image transport\n"
56 "This application sets the following channel variable upon completion:\n"
57 " SENDIMAGESTATUS The status is the attempt to send an image as a text string, one of\n"
64 static int sendimage_exec(struct ast_channel *chan, void *data)
69 int priority_jump = 0;
70 AST_DECLARE_APP_ARGS(args,
71 AST_APP_ARG(filename);
77 if (!(parse = ast_strdupa(data))) {
78 ast_log(LOG_WARNING, "Memory Error!\n");
83 AST_STANDARD_APP_ARGS(args, parse);
85 if (ast_strlen_zero(args.filename)) {
86 ast_log(LOG_WARNING, "SendImage requires an argument (filename[|options])\n");
91 if (strchr(args.options, 'j'))
95 if (!ast_supports_images(chan)) {
96 /* Does not support transport */
97 if (priority_jump || option_priority_jumping)
98 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
99 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
100 LOCAL_USER_REMOVE(u);
104 res = ast_send_image(chan, args.filename);
107 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
109 LOCAL_USER_REMOVE(u);
114 int unload_module(void)
118 res = ast_unregister_application(app);
120 STANDARD_HANGUP_LOCALUSERS;
125 int load_module(void)
127 return ast_register_application(app, sendimage_exec, synopsis, descrip);
130 char *description(void)
138 STANDARD_USECOUNT(res);
144 return ASTERISK_GPL_KEY;