Asterisk - The Open Source Telephony Project  18.5.0
app_image.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <[email protected]>
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 <[email protected]>
24  *
25  * \ingroup applications
26  */
27 
28 /*** MODULEINFO
29  <support_level>deprecated</support_level>
30  ***/
31 
32 #include "asterisk.h"
33 
34 #include "asterisk/pbx.h"
35 #include "asterisk/module.h"
36 #include "asterisk/image.h"
37 
38 static char *app = "SendImage";
39 
40 /*** DOCUMENTATION
41  <application name="SendImage" language="en_US">
42  <synopsis>
43  Sends an image file.
44  </synopsis>
45  <syntax>
46  <parameter name="filename" required="true">
47  <para>Path of the filename (image) to send.</para>
48  </parameter>
49  </syntax>
50  <description>
51  <para>Send an image file on a channel supporting it.</para>
52  <para>Result of transmission will be stored in <variable>SENDIMAGESTATUS</variable></para>
53  <variablelist>
54  <variable name="SENDIMAGESTATUS">
55  <value name="SUCCESS">
56  Transmission succeeded.
57  </value>
58  <value name="FAILURE">
59  Transmission failed.
60  </value>
61  <value name="UNSUPPORTED">
62  Image transmission not supported by channel.
63  </value>
64  </variable>
65  </variablelist>
66  </description>
67  <see-also>
68  <ref type="application">SendText</ref>
69  <ref type="application">SendURL</ref>
70  </see-also>
71  </application>
72  ***/
73 
74 static int sendimage_exec(struct ast_channel *chan, const char *data)
75 {
76 
77  if (ast_strlen_zero(data)) {
78  ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
79  return -1;
80  }
81 
82  if (!ast_supports_images(chan)) {
83  /* Does not support transport */
84  pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED");
85  return 0;
86  }
87 
88  if (!ast_send_image(chan, data)) {
89  pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS");
90  } else {
91  pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE");
92  }
93 
94  return 0;
95 }
96 
97 static int unload_module(void)
98 {
100 }
101 
102 static int load_module(void)
103 {
105 }
106 
107 AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Image Transmission Application");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
#define LOG_WARNING
Definition: logger.h:274
static int sendimage_exec(struct ast_channel *chan, const char *data)
Definition: app_image.c:74
static char * app
Definition: app_image.c:38
AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Image Transmission Application")
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
int ast_send_image(struct ast_channel *chan, const char *filename)
Sends an image.
Definition: image.c:158
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
General Asterisk channel definitions for image handling.
static int unload_module(void)
Definition: app_image.c:97
Core PBX routines and definitions.
int ast_supports_images(struct ast_channel *chan)
Check for image support on a channel.
Definition: image.c:67
static int load_module(void)
Definition: app_image.c:102
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name...
void * data
Definition: pbx.c:248
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
Asterisk module definitions.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626