app_image.c

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Mark Spencer <markster@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 /*! \file
00020  *
00021  * \brief App to transmit an image
00022  *
00023  * \author Mark Spencer <markster@digium.com>
00024  * 
00025  * \ingroup applications
00026  */
00027 
00028 /*** MODULEINFO
00029    <support_level>extended</support_level>
00030  ***/
00031  
00032 #include "asterisk.h"
00033 
00034 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 419592 $")
00035 
00036 #include "asterisk/pbx.h"
00037 #include "asterisk/module.h"
00038 #include "asterisk/image.h"
00039 
00040 static char *app = "SendImage";
00041 
00042 /*** DOCUMENTATION
00043    <application name="SendImage" language="en_US">
00044       <synopsis>
00045          Sends an image file.
00046       </synopsis>
00047       <syntax>
00048          <parameter name="filename" required="true">
00049             <para>Path of the filename (image) to send.</para>
00050          </parameter>
00051       </syntax>
00052       <description>
00053          <para>Send an image file on a channel supporting it.</para>
00054          <para>Result of transmission will be stored in <variable>SENDIMAGESTATUS</variable></para>
00055          <variablelist>
00056             <variable name="SENDIMAGESTATUS">
00057                <value name="SUCCESS">
00058                   Transmission succeeded.
00059                </value>
00060                <value name="FAILURE">
00061                   Transmission failed.
00062                </value>
00063                <value name="UNSUPPORTED">
00064                   Image transmission not supported by channel.
00065                </value>
00066             </variable>
00067          </variablelist>
00068       </description>
00069       <see-also>
00070          <ref type="application">SendText</ref>
00071          <ref type="application">SendURL</ref>
00072       </see-also>
00073    </application>
00074  ***/
00075 
00076 static int sendimage_exec(struct ast_channel *chan, const char *data)
00077 {
00078 
00079    if (ast_strlen_zero(data)) {
00080       ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
00081       return -1;
00082    }
00083 
00084    if (!ast_supports_images(chan)) {
00085       /* Does not support transport */
00086       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED");
00087       return 0;
00088    }
00089 
00090    if (!ast_send_image(chan, data)) {
00091       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS");
00092    } else {
00093       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE");
00094    }
00095    
00096    return 0;
00097 }
00098 
00099 static int unload_module(void)
00100 {
00101    return ast_unregister_application(app);
00102 }
00103 
00104 static int load_module(void)
00105 {
00106    return ast_register_application_xml(app, sendimage_exec);
00107 }
00108 
00109 AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Image Transmission Application");
00110 

Generated on Thu Apr 16 06:27:09 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6