From 04fc29c8b2e7db9b66a138f47412770867819f7f Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Sat, 2 Oct 2004 00:58:31 +0000 Subject: Huge callerid rework (might break H.323, others) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3874 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- manager.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'manager.c') diff --git a/manager.c b/manager.c index 4f5e568ad..02f730f57 100755 --- a/manager.c +++ b/manager.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,8 @@ struct fast_originate_helper int timeout; char app[256]; char appdata[256]; - char callerid[256]; + char cid_name[256]; + char cid_num[256]; char variable[256]; char account[256]; char context[256]; @@ -693,6 +695,7 @@ static int action_status(struct mansession *s, struct message *m) "Event: Status\r\n" "Channel: %s\r\n" "CallerID: %s\r\n" + "CallerIDName: %s\r\n" "Account: %s\r\n" "State: %s\r\n" "Context: %s\r\n" @@ -703,7 +706,9 @@ static int action_status(struct mansession *s, struct message *m) "Uniqueid: %s\r\n" "%s" "\r\n", - c->name, c->callerid ? c->callerid : "", + c->name, + c->cid.cid_num ? c->cid.cid_num : "", + c->cid.cid_name ? c->cid.cid_name : "", c->accountcode, ast_state2str(c->_state), c->context, c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText); @@ -712,13 +717,16 @@ static int action_status(struct mansession *s, struct message *m) "Event: Status\r\n" "Channel: %s\r\n" "CallerID: %s\r\n" + "CallerIDName: %s\r\n" "Account: %s\r\n" "State: %s\r\n" "%s" "Uniqueid: %s\r\n" "%s" "\r\n", - c->name, c->callerid ? c->callerid : "", + c->name, + c->cid.cid_num ? c->cid.cid_num : "", + c->cid.cid_name ? c->cid.cid_name : "", c->accountcode, ast_state2str(c->_state), bridge, c->uniqueid, idText); } @@ -810,9 +818,15 @@ static void *fast_originate(void *data) int res; int reason = 0; if (!ast_strlen_zero(in->app)) { - res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, !ast_strlen_zero(in->callerid) ? in->callerid : NULL, in->variable, in->account); + res = ast_pbx_outgoing_app(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->app, in->appdata, &reason, 1, + !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, + !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, + in->variable, in->account); } else { - res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, !ast_strlen_zero(in->callerid) ? in->callerid : NULL, in->variable, in->account); + res = ast_pbx_outgoing_exten(in->tech, AST_FORMAT_SLINEAR, in->data, in->timeout, in->context, in->exten, in->priority, &reason, 1, + !ast_strlen_zero(in->cid_num) ? in->cid_num : NULL, + !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL, + in->variable, in->account); } if (!res) manager_event(EVENT_FLAG_CALL, @@ -859,18 +873,21 @@ static int action_originate(struct mansession *s, struct message *m) char *priority = astman_get_header(m, "Priority"); char *timeout = astman_get_header(m, "Timeout"); char *callerid = astman_get_header(m, "CallerID"); - char *variable = astman_get_header(m, "Variable"); - char *account = astman_get_header(m, "Account"); + char *variable = astman_get_header(m, "Variable"); + char *account = astman_get_header(m, "Account"); char *app = astman_get_header(m, "Application"); char *appdata = astman_get_header(m, "Data"); char *async = astman_get_header(m, "Async"); char *id = astman_get_header(m, "ActionID"); char *tech, *data; + char *l=NULL, *n=NULL; int pi = 0; int res; int to = 30000; int reason = 0; char tmp[256]; + char tmp2[256]=""; + pthread_t th; pthread_attr_t attr; if (!name) { @@ -894,6 +911,17 @@ static int action_originate(struct mansession *s, struct message *m) } *data = '\0'; data++; + strncpy(tmp2, callerid, sizeof(tmp2) - 1); + ast_callerid_parse(tmp2, &n, &l); + if (n) { + if (ast_strlen_zero(n)) + n = NULL; + } + if (l) { + ast_shrink_phone_number(l); + if (ast_strlen_zero(l)) + l = NULL; + } if (ast_true(async)) { struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper)); if (!fast) { @@ -906,7 +934,10 @@ static int action_originate(struct mansession *s, struct message *m) strncpy(fast->data, data, sizeof(fast->data) - 1); strncpy(fast->app, app, sizeof(fast->app) - 1); strncpy(fast->appdata, appdata, sizeof(fast->appdata) - 1); - strncpy(fast->callerid, callerid, sizeof(fast->callerid) - 1); + if (l) + strncpy(fast->cid_num, l, sizeof(fast->cid_num) - 1); + if (n) + strncpy(fast->cid_name, n, sizeof(fast->cid_name) - 1); strncpy(fast->variable, variable, sizeof(fast->variable) - 1); strncpy(fast->account, account, sizeof(fast->account) - 1); strncpy(fast->context, context, sizeof(fast->context) - 1); @@ -922,10 +953,10 @@ static int action_originate(struct mansession *s, struct message *m) } } } else if (!ast_strlen_zero(app)) { - res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, !ast_strlen_zero(callerid) ? callerid : NULL, variable, account); + res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 0, l, n, variable, account); } else { if (exten && context && pi) - res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, !ast_strlen_zero(callerid) ? callerid : NULL, variable, account); + res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 0, l, n, variable, account); else { astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'"); return 0; -- cgit v1.2.3