--- manager.c.orig 2007-06-24 10:32:21.000000000 -0700 +++ manager.c 2007-10-04 16:33:31.000000000 -0700 @@ -962,8 +962,13 @@ "Context: %s\r\n" "Exten: %s\r\n" "Reason: %d\r\n" - "Uniqueid: %s\r\n", - in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : ""); + "Uniqueid: %s\r\n" + "CallerID: %s\r\n" + "CallerIDName: %s\r\n", + in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "", + in->cid_num ? in->cid_num : "", + in->cid_name ? in->cid_name : "" + ); else manager_event(EVENT_FLAG_CALL, "OriginateFailure", @@ -972,8 +977,13 @@ "Context: %s\r\n" "Exten: %s\r\n" "Reason: %d\r\n" - "Uniqueid: %s\r\n", - in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : ""); + "Uniqueid: %s\r\n" + "CallerID: %s\r\n" + "CallerIDName: %s\r\n", + in->idtext, in->tech, in->data, in->context, in->exten, reason, chan ? chan->uniqueid : "", + in->cid_num ? in->cid_num : "", + in->cid_name ? in->cid_name : "" + ); /* Locked by ast_pbx_outgoing_exten or ast_pbx_outgoing_app */ if (chan) @@ -1552,6 +1562,47 @@ return 0; } +static char mandescr_sendevent[] = +"Description: Send an event to manager sessions.\n" +"Variables: (Names marked with * are required)\n" +" *Event: EventStringToSend\n" +" Body: Optional string to send.\n"; + +static int action_sendevent(struct mansession *s, struct message *m) +{ + char *event = astman_get_header(m, "Event"); + char *body = astman_get_header(m, "Body"); + + manager_event(EVENT_FLAG_USER, "ManagerUserEvent", "Event: %s\r\nBody: %s\r\n", event, body ? body : ""); + + return 0; +} + +static char mandescr_userevent[] = +"Description: Send an event to manager sessions.\n" +"Variables: (Names marked with * are required)\n" +" *UserEvent: EventStringToSend\n" +" Header1: Content1\n" +" HeaderN: ContentN\n"; + +static int action_userevent(struct mansession *s, struct message *m) +{ + const char *event = astman_get_header(m, "UserEvent"); + char body[2048] = ""; + int x, bodylen = 0; + for (x = 0; x < m->hdrcount; x++) { + if (strncasecmp("UserEvent:", m->headers[x], strlen("UserEvent:"))) { + ast_copy_string(body + bodylen, m->headers[x], sizeof(body) - bodylen - 3); + bodylen += strlen(m->headers[x]); + ast_copy_string(body + bodylen, "\r\n", 3); + bodylen += 2; + } + } + + manager_event(EVENT_FLAG_USER, "UserEvent", "UserEvent: %s\r\n%s", event, body); + return 0; +} + int ast_manager_unregister( char *action ) { struct manager_action *cur = first_action, *prev = first_action; @@ -1664,6 +1715,8 @@ ast_manager_register("Status", EVENT_FLAG_CALL, action_status, "Lists channel status" ); ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar ); ast_manager_register2("Getvar", EVENT_FLAG_CALL, action_getvar, "Gets a Channel Variable", mandescr_getvar ); + ast_manager_register2("SendEvent", EVENT_FLAG_USER, action_sendevent, "Send Manager Event", mandescr_sendevent ); + ast_manager_register2("UserEvent", EVENT_FLAG_USER, action_userevent, "Send an arbitrary event", mandescr_userevent); ast_manager_register2("Redirect", EVENT_FLAG_CALL, action_redirect, "Redirect (transfer) a call", mandescr_redirect ); ast_manager_register2("Originate", EVENT_FLAG_CALL, action_originate, "Originate Call", mandescr_originate); ast_manager_register2("Command", EVENT_FLAG_COMMAND, action_command, "Execute Asterisk CLI Command", mandescr_command );