#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/app.h"
#include "asterisk/options.h"
Go to the source code of this file.
Functions | |
char * | description (void) |
Provides a description of the module. | |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
static int | sendimage_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "SendImage" |
static char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Send an image file" |
static char * | tdesc = "Image Transmission Application" |
Definition in file app_image.c.
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 132 of file app_image.c.
00133 { 00134 return tdesc; 00135 }
char* key | ( | void | ) |
Returns the ASTERISK_GPL_KEY.
This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 144 of file app_image.c.
References ASTERISK_GPL_KEY.
00145 { 00146 return ASTERISK_GPL_KEY; 00147 }
int load_module | ( | void | ) |
Initialize the module.
Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 127 of file app_image.c.
References ast_register_application(), and sendimage_exec().
00128 { 00129 return ast_register_application(app, sendimage_exec, synopsis, descrip); 00130 }
static int sendimage_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 66 of file app_image.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_goto_if_exists(), ast_log(), ast_send_image(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_supports_images(), localuser::chan, ast_channel::context, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_WARNING, option_priority_jumping, parse(), and pbx_builtin_setvar_helper().
Referenced by load_module().
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 /* Does not support transport */ 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 }
int unload_module | ( | void | ) |
Cleanup all module structures, sockets, etc.
This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 116 of file app_image.c.
References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00117 { 00118 int res; 00119 00120 res = ast_unregister_application(app); 00121 00122 STANDARD_HANGUP_LOCALUSERS; 00123 00124 return res; 00125 }
int usecount | ( | void | ) |
Provides a usecount.
This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 137 of file app_image.c.
References STANDARD_USECOUNT.
00138 { 00139 int res; 00140 STANDARD_USECOUNT(res); 00141 return res; 00142 }
char* app = "SendImage" [static] |
Definition at line 47 of file app_image.c.
char* descrip [static] |
Definition at line 51 of file app_image.c.
Definition at line 64 of file app_image.c.
Definition at line 62 of file app_image.c.
char* synopsis = "Send an image file" [static] |
Definition at line 49 of file app_image.c.
char* tdesc = "Image Transmission Application" [static] |
Definition at line 45 of file app_image.c.