Wed Jan 8 2020 09:49:39

Asterisk developer's documentation


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 <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: 328209 $")
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 {
107 }
108 
109 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:396
Asterisk main include file. File version handling, generic pbx functions.
#define LOG_WARNING
Definition: logger.h:144
static int sendimage_exec(struct ast_channel *chan, const char *data)
Definition: app_image.c:76
static char * app
Definition: app_image.c:40
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
int ast_send_image(struct ast_channel *chan, const char *filename)
Sends an image.
Definition: image.c:159
General Asterisk channel definitions for image handling.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
static int unload_module(void)
Definition: app_image.c:99
int ast_supports_images(struct ast_channel *chan)
Check for image support on a channel.
Definition: image.c:69
static int load_module(void)
Definition: app_image.c:104
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
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...
Definition: pbx.c:10546
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
union ast_frame::@172 data
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180