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