re-doxygen some comments
[asterisk-bristuff.git] / apps / app_image.c
blobf5f32719711555a1c524eaf0a6b72800fea2d23b
1 /*
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.
19 /*! \file
21 * \brief App to transmit an image
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
28 #include "asterisk.h"
30 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
32 #include <stdlib.h>
33 #include <stdio.h>
34 #include <string.h>
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/translate.h"
43 #include "asterisk/image.h"
44 #include "asterisk/app.h"
45 #include "asterisk/options.h"
47 static char *app = "SendImage";
49 static char *synopsis = "Send an image file";
51 static char *descrip =
52 " SendImage(filename): Sends an image on a channel. \n"
53 "If the channel supports image transport but the image send\n"
54 "fails, the channel will be hung up. Otherwise, the dialplan\n"
55 "continues execution.\n"
56 "The option string may contain the following character:\n"
57 " 'j' -- jump to priority n+101 if the channel doesn't support image transport\n"
58 "This application sets the following channel variable upon completion:\n"
59 " SENDIMAGESTATUS The status is the result of the attempt as a text string, one of\n"
60 " OK | NOSUPPORT \n";
63 static int sendimage_exec(struct ast_channel *chan, void *data)
65 int res = 0;
66 struct ast_module_user *u;
67 char *parse;
68 int priority_jump = 0;
69 AST_DECLARE_APP_ARGS(args,
70 AST_APP_ARG(filename);
71 AST_APP_ARG(options);
74 u = ast_module_user_add(chan);
76 parse = ast_strdupa(data);
78 AST_STANDARD_APP_ARGS(args, parse);
80 if (ast_strlen_zero(args.filename)) {
81 ast_log(LOG_WARNING, "SendImage requires an argument (filename[|options])\n");
82 return -1;
85 if (args.options) {
86 if (strchr(args.options, 'j'))
87 priority_jump = 1;
90 if (!ast_supports_images(chan)) {
91 /* Does not support transport */
92 if (priority_jump || ast_opt_priority_jumping)
93 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
94 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
95 ast_module_user_remove(u);
96 return 0;
99 res = ast_send_image(chan, args.filename);
101 if (!res)
102 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
104 ast_module_user_remove(u);
106 return res;
109 static int unload_module(void)
111 int res;
113 res = ast_unregister_application(app);
115 ast_module_user_hangup_all();
117 return res;
120 static int load_module(void)
122 return ast_register_application(app, sendimage_exec, synopsis, descrip);
125 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");