Mon Jun 27 16:50:46 2011

Asterisk developer's documentation


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 #include "asterisk.h"
00029 
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 196072 $")
00031 
00032 #include "asterisk/pbx.h"
00033 #include "asterisk/module.h"
00034 #include "asterisk/image.h"
00035 
00036 static char *app = "SendImage";
00037 
00038 /*** DOCUMENTATION
00039    <application name="SendImage" language="en_US">
00040       <synopsis>
00041          Sends an image file.
00042       </synopsis>
00043       <syntax>
00044          <parameter name="filename" required="true">
00045             <para>Path of the filename (image) to send.</para>
00046          </parameter>
00047       </syntax>
00048       <description>
00049          <para>Send an image file on a channel supporting it.</para>
00050          <para>Result of transmission will be stored in <variable>SENDIMAGESTATUS</variable></para>
00051          <variablelist>
00052             <variable name="SENDIMAGESTATUS">
00053                <value name="SUCCESS">
00054                   Transmission succeeded.
00055                </value>
00056                <value name="FAILURE">
00057                   Transmission failed.
00058                </value>
00059                <value name="UNSUPPORTED">
00060                   Image transmission not supported by channel.
00061                </value>
00062             </variable>
00063          </variablelist>
00064       </description>
00065       <see-also>
00066          <ref type="application">SendText</ref>
00067          <ref type="application">SendURL</ref>
00068       </see-also>
00069    </application>
00070  ***/
00071 
00072 static int sendimage_exec(struct ast_channel *chan, const char *data)
00073 {
00074 
00075    if (ast_strlen_zero(data)) {
00076       ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
00077       return -1;
00078    }
00079 
00080    if (!ast_supports_images(chan)) {
00081       /* Does not support transport */
00082       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "UNSUPPORTED");
00083       return 0;
00084    }
00085 
00086    if (!ast_send_image(chan, data)) {
00087       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "SUCCESS");
00088    } else {
00089       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "FAILURE");
00090    }
00091    
00092    return 0;
00093 }
00094 
00095 static int unload_module(void)
00096 {
00097    return ast_unregister_application(app);
00098 }
00099 
00100 static int load_module(void)
00101 {
00102    return ast_register_application_xml(app, sendimage_exec);
00103 }
00104 
00105 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");

Generated on Mon Jun 27 16:50:46 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7