]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Sat, 11 Feb 2006 19:03:03 +0000 (19:03 +0000)
committerAutomerge script <automerge@asterisk.org>
Sat, 11 Feb 2006 19:03:03 +0000 (19:03 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@9606 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channel.c
include/asterisk/channel.h
include/asterisk/manager.h
include/asterisk/pbx.h
manager.c
pbx.c
pbx/pbx_spool.c

index 8f33914244b518549c56238711683d6f66a2369c..190c4a31059545e609004c1eb83a85cf9efa7eb9 100644 (file)
--- a/channel.c
+++ b/channel.c
@@ -2381,6 +2381,8 @@ struct ast_channel *__ast_request_and_dial(const char *type, int format, void *d
                                ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
                        if (oh->parent_channel)
                                ast_channel_inherit_variables(oh->parent_channel, chan);
+                       if (oh->account)
+                               ast_cdr_setaccount(chan, oh->account);  
                }
                ast_set_callerid(chan, cid_num, cid_name, cid_num);
 
index 6a4ff373f77bf5eb9babc0c6b5d18b78861cf7e3..11fb0a7d0331892f1f422997858cc810e47ac939 100644 (file)
@@ -469,6 +469,7 @@ struct chanmon;
        oh.priority = priority; \
        oh.cid_num = cid_num; \
        oh.cid_name = cid_name; \
+       oh.account = account; \
        oh.vars = vars; \
        oh.parent_channel = NULL; \
 } 
@@ -479,6 +480,7 @@ struct outgoing_helper {
        int priority;
        const char *cid_num;
        const char *cid_name;
+       const char *account;
        struct ast_variable *vars;
        struct ast_channel *parent_channel;
 };
index 614eeff4597d615c019787f29562bbd69d13fe0b..dc1e30063c6cfc00c532f35c8cff8fe40da8a0eb 100644 (file)
@@ -56,8 +56,8 @@
 #define EVENT_FLAG_USER                 (1 << 6) /* Ability to read/set user info */
 
 /* Export manager structures */
-#define MAX_HEADERS 80
-#define MAX_LEN 256
+#define AST_MAX_MANHEADERS 80
+#define AST_MAX_MANHEADER_LEN 256
 
 struct eventqent {
        struct eventqent *next;
@@ -88,7 +88,7 @@ struct mansession {
        /*! Authorization for writing */
        int writeperm;
        /*! Buffer */
-       char inbuf[MAX_LEN];
+       char inbuf[AST_MAX_MANHEADER_LEN];
        int inlen;
        int send_events;
        /* Queued events that we've not had the ability to send yet */
@@ -101,7 +101,7 @@ struct mansession {
 
 struct message {
        int hdrcount;
-       char headers[MAX_HEADERS][MAX_LEN];
+       char headers[AST_MAX_MANHEADERS][AST_MAX_MANHEADER_LEN];
 };
 
 struct manager_action {
index a105461741afb37deb2906cbb206581d473352fb..d2902002c455b612d856215a571d2fbd78fda55d 100644 (file)
@@ -563,11 +563,11 @@ int ast_async_goto_by_name(const char *chan, const char *context, const char *ex
 
 /* Synchronously or asynchronously make an outbound call and send it to a
    particular extension */
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /* Synchronously or asynchronously make an outbound call and send it to a
    particular application with given extension */
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel);
+int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel);
 
 /* Functions for returning values from structures */
 const char *ast_get_context_name(struct ast_context *con);
index fe8d03726f7ef6c4e1d4f281b3b770101f28fe47..5254f77496ab17920423682df840c9324e6f4d7c 100644 (file)
--- a/manager.c
+++ b/manager.c
@@ -64,16 +64,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/utils.h"
 
 struct fast_originate_helper {
-       char tech[256];
-       char data[256];
+       char tech[AST_MAX_MANHEADER_LEN];
+       char data[AST_MAX_MANHEADER_LEN];
        int timeout;
-       char app[256];
-       char appdata[256];
-       char cid_name[256];
-       char cid_num[256];
-       char context[256];
-       char exten[256];
-       char idtext[256];
+       char app[AST_MAX_APP];
+       char appdata[AST_MAX_MANHEADER_LEN];
+       char cid_name[AST_MAX_MANHEADER_LEN];
+       char cid_num[AST_MAX_MANHEADER_LEN];
+       char context[AST_MAX_CONTEXT];
+       char exten[AST_MAX_EXTENSION];
+       char idtext[AST_MAX_MANHEADER_LEN];
+       char account[AST_MAX_ACCOUNT_CODE];
        int priority;
        struct ast_variable *vars;
 };
@@ -939,12 +940,12 @@ static void *fast_originate(void *data)
                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->vars, &chan);
+                       in->vars, in->account, &chan);
        } 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->cid_num) ? in->cid_num : NULL, 
                        !ast_strlen_zero(in->cid_name) ? in->cid_name : NULL,
-                       in->vars, &chan);
+                       in->vars, in->account, &chan);
        }   
        if (!res)
                manager_event(EVENT_FLAG_CALL,
@@ -1047,12 +1048,6 @@ static int action_originate(struct mansession *s, struct message *m)
                if (ast_strlen_zero(l))
                        l = NULL;
        }
-       if (account) {
-               struct ast_variable *newvar;
-               newvar = ast_variable_new("CDR(accountcode|r)", account);
-               newvar->next = vars;
-               vars = newvar;
-       }
        if (ast_true(async)) {
                struct fast_originate_helper *fast = malloc(sizeof(struct fast_originate_helper));
                if (!fast) {
@@ -1072,6 +1067,7 @@ static int action_originate(struct mansession *s, struct message *m)
                        fast->vars = vars;      
                        ast_copy_string(fast->context, context, sizeof(fast->context));
                        ast_copy_string(fast->exten, exten, sizeof(fast->exten));
+                       ast_copy_string(fast->account, account, sizeof(fast->account));
                        fast->timeout = to;
                        fast->priority = pi;
                        pthread_attr_init(&attr);
@@ -1083,10 +1079,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, 1, l, n, vars, NULL);
+               res = ast_pbx_outgoing_app(tech, AST_FORMAT_SLINEAR, data, to, app, appdata, &reason, 1, l, n, vars, account, NULL);
        } else {
                if (exten && context && pi)
-                       res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, NULL);
+                       res = ast_pbx_outgoing_exten(tech, AST_FORMAT_SLINEAR, data, to, context, exten, pi, &reason, 1, l, n, vars, account, NULL);
                else {
                        astman_send_error(s, m, "Originate with 'Exten' requires 'Context' and 'Priority'");
                        return 0;
@@ -1405,7 +1401,7 @@ static void *session_do(void *data)
                                if (process_message(s, &m))
                                        break;
                                memset(&m, 0, sizeof(m));
-                       } else if (m.hdrcount < MAX_HEADERS - 1)
+                       } else if (m.hdrcount < AST_MAX_MANHEADERS - 1)
                                m.hdrcount++;
                } else if (res < 0)
                        break;
diff --git a/pbx.c b/pbx.c
index a07a66a1b3344ca50a518ccabb901ffa3cf45541..f7d26c92aacd8236db46cc93c70e0d84f0a0cf5a 100644 (file)
--- a/pbx.c
+++ b/pbx.c
@@ -4957,7 +4957,7 @@ int ast_pbx_outgoing_cdr_failed(void)
        return 0;  /* success */
 }
 
-int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **channel)
+int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout, const char *context, const char *exten, int priority, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **channel)
 {
        struct ast_channel *chan;
        struct async_stat *as;
@@ -4974,7 +4974,7 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
                                ast_mutex_lock(&chan->lock);
                }
                if (chan) {
-                       if(chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
+                       if (chan->cdr) { /* check if the channel already has a cdr record, if not give it one */
                                ast_log(LOG_WARNING, "%s already has a call record??\n", chan->name);
                        } else {
                                chan->cdr = ast_cdr_alloc();   /* allocate a cdr for the channel */
@@ -5051,6 +5051,8 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
                                        ast_copy_string(chan->exten, "failed", sizeof(chan->exten));
                                        chan->priority = 1;
                                        ast_set_variables(chan, vars);
+                                       if (account)
+                                               ast_cdr_setaccount(chan, account);
                                        ast_pbx_run(chan);      
                                } else 
                                        ast_log(LOG_WARNING, "Can't allocate the channel structure, skipping execution of extension 'failed'\n");
@@ -5080,6 +5082,8 @@ int ast_pbx_outgoing_exten(const char *type, int format, void *data, int timeout
                as->priority = priority;
                as->timeout = timeout;
                ast_set_variables(chan, vars);
+               if (account)
+                       ast_cdr_setaccount(chan, account);
                pthread_attr_init(&attr);
                pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
                if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
@@ -5121,7 +5125,7 @@ static void *ast_pbx_run_app(void *data)
        return NULL;
 }
 
-int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, struct ast_channel **locked_channel)
+int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout, const char *app, const char *appdata, int *reason, int sync, const char *cid_num, const char *cid_name, struct ast_variable *vars, const char *account, struct ast_channel **locked_channel)
 {
        struct ast_channel *chan;
        struct async_stat *as;
@@ -5129,9 +5133,10 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
        int res = -1, cdr_res = -1;
        struct outgoing_helper oh;
        pthread_attr_t attr;
-       
+
        memset(&oh, 0, sizeof(oh));
-       oh.vars = vars; 
+       oh.vars = vars;
+       oh.account = account;   
 
        if (locked_channel) 
                *locked_channel = NULL;
@@ -5158,6 +5163,8 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
                                ast_cdr_start(chan->cdr);
                        }
                        ast_set_variables(chan, vars);
+                       if (account)
+                               ast_cdr_setaccount(chan, account);
                        if (chan->_state == AST_STATE_UP) {
                                res = 0;
                                if (option_verbose > 3)
@@ -5237,6 +5244,8 @@ int ast_pbx_outgoing_app(const char *type, int format, void *data, int timeout,
                        ast_copy_string(as->appdata,  appdata, sizeof(as->appdata));
                as->timeout = timeout;
                ast_set_variables(chan, vars);
+               if (account)
+                       ast_cdr_setaccount(chan, account);
                /* Start a new thread, and get something handling this channel. */
                pthread_attr_init(&attr);
                pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
index a7dbed32cc4d746ddc95a576a9556f86fa5d0b4d..a91a7e255bb49e2570b0ae12aa60a30a8d43e808 100644 (file)
@@ -86,6 +86,9 @@ struct outgoing {
        char cid_num[256];
        char cid_name[256];
 
+       /* account code */
+       char account[AST_MAX_ACCOUNT_CODE];
+
        /* Variables and Functions */
        struct ast_variable *vars;
        
@@ -212,11 +215,7 @@ static int apply_outgoing(struct outgoing *o, char *fn, FILE *f)
                                                ast_log(LOG_WARNING, "Malformed Set: argument! Should be Set: Variable=value\n");
                                        }
                                } else if (!strcasecmp(buf, "account")) {
-                                       var = ast_variable_new("CDR(accountcode|r)", c);
-                                       if (var) {      
-                                               var->next = o->vars;
-                                               o->vars = var;
-                                       }
+                                       ast_copy_string(o->account, c, sizeof(o->account));
                                } else {
                                        ast_log(LOG_WARNING, "Unknown keyword '%s' at line %d of %s\n", buf, lineno, fn);
                                }
@@ -260,11 +259,11 @@ static void *attempt_thread(void *data)
        if (!ast_strlen_zero(o->app)) {
                if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for application %s(%s) (Retry %d)\n", o->tech, o->dest, o->app, o->data, o->retries);
-               res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
+               res = ast_pbx_outgoing_app(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->app, o->data, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
        } else {
                if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "Attempting call on %s/%s for %s@%s:%d (Retry %d)\n", o->tech, o->dest, o->exten, o->context,o->priority, o->retries);
-               res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, NULL);
+               res = ast_pbx_outgoing_exten(o->tech, AST_FORMAT_SLINEAR, o->dest, o->waittime * 1000, o->context, o->exten, o->priority, &reason, 2 /* wait to finish */, o->cid_num, o->cid_name, o->vars, o->account, NULL);
        }
        if (res) {
                ast_log(LOG_NOTICE, "Call failed to go through, reason %d\n", reason);