#include "asterisk.h"
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/config.h"
#include "asterisk/manager.h"
#include "asterisk/utils.h"
Include dependency graph for app_setcdruserfield.c:
Go to the source code of this file.
Functions | |
static int | action_setcdruserfield (struct mansession *s, const struct message *m) |
static int | appendcdruserfield_exec (struct ast_channel *chan, void *data) |
AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"CDR user field apps") | |
static int | load_module (void) |
static int | setcdruserfield_exec (struct ast_channel *chan, void *data) |
static int | unload_module (void) |
Variables | |
static char * | appendcdruserfield_app = "AppendCDRUserField" |
static char * | appendcdruserfield_descrip |
static char * | appendcdruserfield_synopsis = "Append to the CDR user field" |
static char * | setcdruserfield_app = "SetCDRUserField" |
static char * | setcdruserfield_descrip |
static char * | setcdruserfield_synopsis = "Set the CDR user field" |
Definition in file app_setcdruserfield.c.
static int action_setcdruserfield | ( | struct mansession * | s, | |
const struct message * | m | |||
) | [static] |
Definition at line 78 of file app_setcdruserfield.c.
References ast_cdr_appenduserfield(), ast_cdr_setuserfield(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strlen_zero(), ast_true(), astman_get_header(), astman_send_ack(), astman_send_error(), s, and userfield.
Referenced by load_module().
00079 { 00080 struct ast_channel *c = NULL; 00081 const char *userfield = astman_get_header(m, "UserField"); 00082 const char *channel = astman_get_header(m, "Channel"); 00083 const char *append = astman_get_header(m, "Append"); 00084 00085 if (ast_strlen_zero(channel)) { 00086 astman_send_error(s, m, "No Channel specified"); 00087 return 0; 00088 } 00089 if (ast_strlen_zero(userfield)) { 00090 astman_send_error(s, m, "No UserField specified"); 00091 return 0; 00092 } 00093 c = ast_get_channel_by_name_locked(channel); 00094 if (!c) { 00095 astman_send_error(s, m, "No such channel"); 00096 return 0; 00097 } 00098 if (ast_true(append)) 00099 ast_cdr_appenduserfield(c, userfield); 00100 else 00101 ast_cdr_setuserfield(c, userfield); 00102 ast_mutex_unlock(&c->lock); 00103 astman_send_ack(s, m, "CDR Userfield Set"); 00104 return 0; 00105 }
static int appendcdruserfield_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 129 of file app_setcdruserfield.c.
References ast_cdr_appenduserfield(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_channel::cdr, ast_module_user::chan, and LOG_WARNING.
Referenced by load_module().
00130 { 00131 struct ast_module_user *u; 00132 int res = 0; 00133 static int dep_warning = 0; 00134 00135 u = ast_module_user_add(chan); 00136 00137 if (chan->cdr && data) { 00138 ast_cdr_appenduserfield(chan, (char*)data); 00139 } 00140 00141 if (!dep_warning) { 00142 dep_warning = 1; 00143 ast_log(LOG_WARNING, "AppendCDRUserField is deprecated. Please use CDR(userfield) instead.\n"); 00144 } 00145 00146 ast_module_user_remove(u); 00147 00148 return res; 00149 }
AST_MODULE_INFO_STANDARD | ( | ASTERISK_GPL_KEY | , | |
"CDR user field apps" | ||||
) |
static int load_module | ( | void | ) | [static] |
Definition at line 164 of file app_setcdruserfield.c.
References action_setcdruserfield(), appendcdruserfield_exec(), ast_manager_register, ast_register_application(), EVENT_FLAG_CALL, and setcdruserfield_exec().
00165 { 00166 int res; 00167 00168 res = ast_register_application(setcdruserfield_app, setcdruserfield_exec, setcdruserfield_synopsis, setcdruserfield_descrip); 00169 res |= ast_register_application(appendcdruserfield_app, appendcdruserfield_exec, appendcdruserfield_synopsis, appendcdruserfield_descrip); 00170 res |= ast_manager_register("SetCDRUserField", EVENT_FLAG_CALL, action_setcdruserfield, "Set the CDR UserField"); 00171 00172 return res; 00173 }
static int setcdruserfield_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 107 of file app_setcdruserfield.c.
References ast_cdr_setuserfield(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_channel::cdr, ast_module_user::chan, and LOG_WARNING.
Referenced by load_module().
00108 { 00109 struct ast_module_user *u; 00110 int res = 0; 00111 static int dep_warning = 0; 00112 00113 u = ast_module_user_add(chan); 00114 00115 if (chan->cdr && data) { 00116 ast_cdr_setuserfield(chan, (char*)data); 00117 } 00118 00119 if (!dep_warning) { 00120 dep_warning = 1; 00121 ast_log(LOG_WARNING, "SetCDRUserField is deprecated. Please use CDR(userfield) instead.\n"); 00122 } 00123 00124 ast_module_user_remove(u); 00125 00126 return res; 00127 }
static int unload_module | ( | void | ) | [static] |
Definition at line 151 of file app_setcdruserfield.c.
References ast_manager_unregister(), ast_module_user_hangup_all, and ast_unregister_application().
00152 { 00153 int res; 00154 00155 res = ast_unregister_application(setcdruserfield_app); 00156 res |= ast_unregister_application(appendcdruserfield_app); 00157 res |= ast_manager_unregister("SetCDRUserField"); 00158 00159 ast_module_user_hangup_all(); 00160 00161 return res; 00162 }
char* appendcdruserfield_app = "AppendCDRUserField" [static] |
Definition at line 74 of file app_setcdruserfield.c.
char* appendcdruserfield_descrip [static] |
Definition at line 62 of file app_setcdruserfield.c.
char* appendcdruserfield_synopsis = "Append to the CDR user field" [static] |
Definition at line 75 of file app_setcdruserfield.c.
char* setcdruserfield_app = "SetCDRUserField" [static] |
Definition at line 59 of file app_setcdruserfield.c.
char* setcdruserfield_descrip [static] |
Definition at line 46 of file app_setcdruserfield.c.
char* setcdruserfield_synopsis = "Set the CDR user field" [static] |
Definition at line 60 of file app_setcdruserfield.c.