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