e74397c0dedbd443400399be9a717bb0357afd6e
[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         </application>
66  ***/
67
68 static int sendimage_exec(struct ast_channel *chan, void *data)
69 {
70
71         if (ast_strlen_zero(data)) {
72                 ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
73                 return -1;
74         }
75
76         if (!ast_supports_images(chan)) {
77                 /* Does not support transport */
78                 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED");
79                 return 0;
80         }
81
82         if (!ast_send_image(chan, data)) {
83                 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS");
84         } else {
85                 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE");
86         }
87         
88         return 0;
89 }
90
91 static int unload_module(void)
92 {
93         return ast_unregister_application(app);
94 }
95
96 static int load_module(void)
97 {
98         return ast_register_application_xml(app, sendimage_exec);
99 }
100
101 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");