--- manager.c 9 Mar 2004 20:01:46 -0000 1.41 +++ manager.c 25 Mar 2004 18:56:12 -0000 @@ -37,6 +37,7 @@ #include #include #include +#include static int enabled = 0; static int portno = DEFAULT_MANAGER_PORT; @@ -379,6 +380,64 @@ return 0; } +static int action_setcdruserfield(struct mansession *s, struct message *m) +{ + struct ast_channel *c = NULL; + char *value = astman_get_header(m, "value"); + if (!strlen(value)) { + astman_send_error(s, m, "No value Specified"); + return 0; + } + char *name = astman_get_header(m, "Channel"); + if (!strlen(name)) { + astman_send_error(s, m, "No channel specified"); + return 0; + } + c = ast_channel_walk(NULL); + while(c) { + if (!strcasecmp(c->name, name)) { + break; + } + c = ast_channel_walk(c); + } + if (!c) { + astman_send_error(s, m, "No such channel"); + return 0; + } + ast_cdr_setuserfield(c, value); + astman_send_ack(s, m, "Channel CDR Userfield Set"); + return 0; +} + +static int action_appendcdruserfield(struct mansession *s, struct message *m) +{ + struct ast_channel *c = NULL; + char *value = astman_get_header(m, "value"); + if (!strlen(value)) { + astman_send_error(s, m, "No value Specified"); + return 0; + } + char *name = astman_get_header(m, "Channel"); + if (!strlen(name)) { + astman_send_error(s, m, "No channel specified"); + return 0; + } + c = ast_channel_walk(NULL); + while(c) { + if (!strcasecmp(c->name, name)) { + break; + } + c = ast_channel_walk(c); + } + if (!c) { + astman_send_error(s, m, "No such channel"); + return 0; + } + ast_cdr_setuserfield(c, value); + astman_send_ack(s, m, "Channel CDR Userfield Appended"); + return 0; +} + static int action_status(struct mansession *s, struct message *m) { char *id = astman_get_header(m,"ActionID"); @@ -955,6 +1014,8 @@ ast_manager_register( "ExtensionState", EVENT_FLAG_CALL, action_extensionstate, "Check Extension Status" ); ast_manager_register( "AbsoluteTimeout", EVENT_FLAG_CALL, action_timeout, "Set Absolute Timeout" ); ast_manager_register( "MailboxCount", EVENT_FLAG_CALL, action_mailboxcount, "Check Mailbox Message Count" ); + ast_manager_register( "SetCDRUserField", EVENT_FLAG_CALL, action_setcdruserfield, "Set the CDR Userfield" ); + ast_manager_register( "AppendCDRUserField", EVENT_FLAG_CALL, action_appendcdruserfield, "Append to the CDR Userfield" ); ast_cli_register(&show_mancmds_cli); ast_cli_register(&show_manconn_cli);