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 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <string.h>
00029
00030 #include "asterisk.h"
00031
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 7221 $")
00033
00034 #include "asterisk/lock.h"
00035 #include "asterisk/file.h"
00036 #include "asterisk/logger.h"
00037 #include "asterisk/channel.h"
00038 #include "asterisk/pbx.h"
00039 #include "asterisk/module.h"
00040 #include "asterisk/translate.h"
00041 #include "asterisk/image.h"
00042 #include "asterisk/app.h"
00043 #include "asterisk/options.h"
00044
00045 static char *tdesc = "Image Transmission Application";
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 STANDARD_LOCAL_USER;
00063
00064 LOCAL_USER_DECL;
00065
00066 static int sendimage_exec(struct ast_channel *chan, void *data)
00067 {
00068 int res = 0;
00069 struct localuser *u;
00070 char *parse;
00071 int priority_jump = 0;
00072 AST_DECLARE_APP_ARGS(args,
00073 AST_APP_ARG(filename);
00074 AST_APP_ARG(options);
00075 );
00076
00077 LOCAL_USER_ADD(u);
00078
00079 if (!(parse = ast_strdupa(data))) {
00080 ast_log(LOG_WARNING, "Memory Error!\n");
00081 LOCAL_USER_REMOVE(u);
00082 return -1;
00083 }
00084
00085 AST_STANDARD_APP_ARGS(args, parse);
00086
00087 if (ast_strlen_zero(args.filename)) {
00088 ast_log(LOG_WARNING, "SendImage requires an argument (filename[|options])\n");
00089 return -1;
00090 }
00091
00092 if (args.options) {
00093 if (strchr(args.options, 'j'))
00094 priority_jump = 1;
00095 }
00096
00097 if (!ast_supports_images(chan)) {
00098
00099 if (priority_jump || option_priority_jumping)
00100 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00101 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "NOSUPPORT");
00102 LOCAL_USER_REMOVE(u);
00103 return 0;
00104 }
00105
00106 res = ast_send_image(chan, args.filename);
00107
00108 if (!res)
00109 pbx_builtin_setvar_helper(chan, "SENDIMAGESTATUS", "OK");
00110
00111 LOCAL_USER_REMOVE(u);
00112
00113 return res;
00114 }
00115
00116 int unload_module(void)
00117 {
00118 int res;
00119
00120 res = ast_unregister_application(app);
00121
00122 STANDARD_HANGUP_LOCALUSERS;
00123
00124 return res;
00125 }
00126
00127 int load_module(void)
00128 {
00129 return ast_register_application(app, sendimage_exec, synopsis, descrip);
00130 }
00131
00132 char *description(void)
00133 {
00134 return tdesc;
00135 }
00136
00137 int usecount(void)
00138 {
00139 int res;
00140 STANDARD_USECOUNT(res);
00141 return res;
00142 }
00143
00144 char *key()
00145 {
00146 return ASTERISK_GPL_KEY;
00147 }