Thu Jul 9 13:40:18 2009

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: 89518 $")
00031 
00032 #include "asterisk/pbx.h"
00033 #include "asterisk/module.h"
00034 #include "asterisk/image.h"
00035 
00036 static char *app = "SendImage";
00037 
00038 static char *synopsis = "Send an image file";
00039 
00040 static char *descrip = 
00041 "  SendImage(filename): Sends an image on a channel.\n"
00042 "If the channel supports image transport but the image send fails, the channel\n"
00043 "will be hung up.  Otherwise, the dialplan continues execution.  This\n"
00044 "application sets the following channel variable upon completion:\n"
00045 "   SENDIMAGESTATUS  The status is the result of the attempt, one of:\n"
00046 "                    OK | NOSUPPORT \n";        
00047 
00048 
00049 static int sendimage_exec(struct ast_channel *chan, void *data)
00050 {
00051    int res = 0;
00052 
00053    if (ast_strlen_zero(data)) {
00054       ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
00055       return -1;
00056    }
00057 
00058    if (!ast_supports_images(chan)) {
00059       /* Does not support transport */
00060       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
00061       return 0;
00062    }
00063 
00064    if (!(res = ast_send_image(chan, data)))
00065       pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
00066       
00067    return res;
00068 }
00069 
00070 static int unload_module(void)
00071 {
00072    return ast_unregister_application(app);
00073 }
00074 
00075 static int load_module(void)
00076 {
00077    return ast_register_application(app, sendimage_exec, synopsis, descrip);
00078 }
00079 
00080 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");

Generated on Thu Jul 9 13:40:18 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7