00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "asterisk.h"
00029
00030 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 40722 $")
00031
00032 #include <stdlib.h>
00033 #include <stdio.h>
00034 #include <string.h>
00035
00036 #include "asterisk/lock.h"
00037 #include "asterisk/file.h"
00038 #include "asterisk/logger.h"
00039 #include "asterisk/channel.h"
00040 #include "asterisk/pbx.h"
00041 #include "asterisk/module.h"
00042 #include "asterisk/translate.h"
00043 #include "asterisk/image.h"
00044 #include "asterisk/app.h"
00045 #include "asterisk/options.h"
00046
00047 static char *app = "SendImage";
00048
00049 static char *synopsis = "Send an image file";
00050
00051 static char *descrip =
00052 " SendImage(filename): Sends an image on a channel. \n"
00053 "If the channel supports image transport but the image send\n"
00054 "fails, the channel will be hung up. Otherwise, the dialplan\n"
00055 "continues execution.\n"
00056 "The option string may contain the following character:\n"
00057 " 'j' -- jump to priority n+101 if the channel doesn't support image transport\n"
00058 "This application sets the following channel variable upon completion:\n"
00059 " SENDIMAGESTATUS The status is the result of the attempt as a text string, one of\n"
00060 " OK | NOSUPPORT \n";
00061
00062
00063 static int sendimage_exec(struct ast_channel *chan, void *data)
00064 {
00065 int res = 0;
00066 struct ast_module_user *u;
00067 char *parse;
00068 int priority_jump = 0;
00069 AST_DECLARE_APP_ARGS(args,
00070 AST_APP_ARG(filename);
00071 AST_APP_ARG(options);
00072 );
00073
00074 u = ast_module_user_add(chan);
00075
00076 parse = ast_strdupa(data);
00077
00078 AST_STANDARD_APP_ARGS(args, parse);
00079
00080 if (ast_strlen_zero(args.filename)) {
00081 ast_log(LOG_WARNING, "SendImage requires an argument (filename[|options])\n");
00082 return -1;
00083 }
00084
00085 if (args.options) {
00086 if (strchr(args.options, 'j'))
00087 priority_jump = 1;
00088 }
00089
00090 if (!ast_supports_images(chan)) {
00091
00092 if (priority_jump || ast_opt_priority_jumping)
00093 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00094 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
00095 ast_module_user_remove(u);
00096 return 0;
00097 }
00098
00099 res = ast_send_image(chan, args.filename);
00100
00101 if (!res)
00102 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
00103
00104 ast_module_user_remove(u);
00105
00106 return res;
00107 }
00108
00109 static int unload_module(void)
00110 {
00111 int res;
00112
00113 res = ast_unregister_application(app);
00114
00115 ast_module_user_hangup_all();
00116
00117 return res;
00118 }
00119
00120 static int load_module(void)
00121 {
00122 return ast_register_application(app, sendimage_exec, synopsis, descrip);
00123 }
00124
00125 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Image Transmission Application");