aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-02 00:58:31 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2004-10-02 00:58:31 +0000
commit6868babd229a635c5fd89c7b284025a92e0a3f9d (patch)
tree25a4ee6dff29d18acfdfbbc42485333db7aa5311 /apps
parentb201da1a3eb1cae654cdd3fe89ef8f9e55dd0b83 (diff)
Huge callerid rework (might break H.323, others)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3874 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-xapps/Makefile7
-rwxr-xr-xapps/app_alarmreceiver.c4
-rwxr-xr-xapps/app_chanisavail.c4
-rwxr-xr-xapps/app_db.c6
-rwxr-xr-xapps/app_dial.c92
-rwxr-xr-xapps/app_directory.c6
-rwxr-xr-xapps/app_disa.c10
-rwxr-xr-xapps/app_enumlookup.c8
-rwxr-xr-xapps/app_groupcount.c2
-rwxr-xr-xapps/app_hasnewvoicemail.c2
-rwxr-xr-xapps/app_image.c6
-rwxr-xr-xapps/app_lookupblacklist.c28
-rwxr-xr-xapps/app_lookupcidname.c31
-rwxr-xr-xapps/app_macro.c10
-rwxr-xr-xapps/app_meetme.c2
-rwxr-xr-xapps/app_osplookup.c14
-rwxr-xr-xapps/app_parkandannounce.c10
-rwxr-xr-xapps/app_privacy.c11
-rwxr-xr-xapps/app_queue.c56
-rwxr-xr-xapps/app_sendtext.c6
-rwxr-xr-xapps/app_setcallerid.c7
-rwxr-xr-xapps/app_setcidname.c24
-rwxr-xr-xapps/app_setcidnum.c24
-rwxr-xr-xapps/app_sms.c13
-rwxr-xr-xapps/app_system.c2
-rwxr-xr-xapps/app_talkdetect.c4
-rwxr-xr-xapps/app_transfer.c6
-rwxr-xr-xapps/app_txtcidname.c2
-rwxr-xr-xapps/app_url.c8
-rwxr-xr-xapps/app_voicemail.c80
-rwxr-xr-xapps/app_zapateller.c6
31 files changed, 222 insertions, 269 deletions
diff --git a/apps/Makefile b/apps/Makefile
index ebd149c76..ce0fef4ca 100755
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -17,7 +17,7 @@ USE_POSTGRES_VM_INTERFACE=0
#APPS=app_dial.so app_playback.so app_directory.so app_intercom.so app_mp3.so
APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
app_system.so app_echo.so app_record.so app_image.so app_url.so app_disa.so \
- app_qcall.so app_adsiprog.so app_getcpeid.so app_milliwatt.so \
+ app_adsiprog.so app_getcpeid.so app_milliwatt.so \
app_zapateller.so app_setcallerid.so app_festival.so \
app_queue.so app_senddtmf.so app_parkandannounce.so app_striplsd.so \
app_setcidname.so app_lookupcidname.so app_substring.so app_macro.so \
@@ -35,6 +35,11 @@ ifneq (${OSARCH},Darwin)
APPS+=app_intercom.so
endif
+#
+# Obsolete things...
+#
+#APPS+=app_qcall.so
+
#APPS+=app_sql_postgres.so
#APPS+=app_sql_odbc.so
#APPS+=app_rpt.so
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 28d28b4c4..2c95be44c 100755
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -318,8 +318,8 @@ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_chan
char timestamp[80];
/* Extract the caller ID location */
-
- strncpy(workstring, chan->callerid, sizeof(workstring) - 1);
+ if (chan->cid.cid_num)
+ strncpy(workstring, chan->cid.cid_num, sizeof(workstring) - 1);
workstring[sizeof(workstring) - 1] = '\0';
ast_callerid_parse(workstring, &cn, &cl);
diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c
index 4438663ce..d61b0f1d3 100755
--- a/apps/app_chanisavail.c
+++ b/apps/app_chanisavail.c
@@ -3,7 +3,7 @@
*
* Check if Channel is Available
*
- * Copyright (C) 2003, Digium
+ * Copyright (C) 2003-2004, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
* James Golovich <james@gnuinter.net>
@@ -97,7 +97,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
if (res < 1) {
pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
else
return -1;
diff --git a/apps/app_db.c b/apps/app_db.c
index 325b06bbb..2014f7a8f 100755
--- a/apps/app_db.c
+++ b/apps/app_db.c
@@ -3,10 +3,10 @@
*
* Database access functions
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
* Copyright (C) 2003, Jefferson Noxon
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
* Jefferson Noxon <jeff@debian.org>
*
* This program is free software, distributed under the terms of
@@ -200,7 +200,7 @@ static int get_exec (struct ast_channel *chan, void *data)
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "DBget: Value not found in database.\n");
/* Send the call to n+101 priority, where n is the current priority */
- if (ast_exists_extension (chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension (chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
}
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 7f3c3d768..e9c435ff5 100755
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -186,7 +186,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
else if (numnochan)
strncpy(status, "CHANUNAVAIL", statussize - 1);
/* See if there is a special busy message */
- if (ast_exists_extension(in, in->context, in->exten, in->priority + 101, in->callerid))
+ if (ast_exists_extension(in, in->context, in->exten, in->priority + 101, in->cid.cid_num))
in->priority+=100;
} else {
if (option_verbose > 2)
@@ -233,10 +233,12 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
o->stillgoing = 0;
numnochan++;
} else {
- if (o->chan->callerid)
- free(o->chan->callerid);
-
- o->chan->callerid = NULL;
+ if (o->chan->cid.cid_num)
+ free(o->chan->cid.cid_num);
+ o->chan->cid.cid_num = NULL;
+ if (o->chan->cid.cid_name)
+ free(o->chan->cid.cid_name);
+ o->chan->cid.cid_name = NULL;
if (o->forcecallerid) {
char *newcid = NULL;
@@ -245,36 +247,41 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
newcid = in->macroexten;
else
newcid = in->exten;
- o->chan->callerid = strdup(newcid);
+ o->chan->cid.cid_num = strdup(newcid);
strncpy(o->chan->accountcode, winner->accountcode, sizeof(o->chan->accountcode) - 1);
o->chan->cdrflags = winner->cdrflags;
- if (!o->chan->callerid)
+ if (!o->chan->cid.cid_num)
ast_log(LOG_WARNING, "Out of memory\n");
} else {
- if (in->callerid) {
- o->chan->callerid = strdup(in->callerid);
- if (!o->chan->callerid)
+ if (in->cid.cid_num) {
+ o->chan->cid.cid_num = strdup(in->cid.cid_num);
+ if (!o->chan->cid.cid_num)
+ ast_log(LOG_WARNING, "Out of memory\n");
+ }
+ if (in->cid.cid_name) {
+ o->chan->cid.cid_name = strdup(in->cid.cid_name);
+ if (!o->chan->cid.cid_name)
ast_log(LOG_WARNING, "Out of memory\n");
}
strncpy(o->chan->accountcode, in->accountcode, sizeof(o->chan->accountcode) - 1);
o->chan->cdrflags = in->cdrflags;
}
- if (in->ani) {
- if (o->chan->ani)
- free(o->chan->ani);
- o->chan->ani = malloc(strlen(in->ani) + 1);
- if (o->chan->ani)
- strncpy(o->chan->ani, in->ani, strlen(in->ani));
+ if (in->cid.cid_ani) {
+ if (o->chan->cid.cid_ani)
+ free(o->chan->cid.cid_ani);
+ o->chan->cid.cid_ani = malloc(strlen(in->cid.cid_ani) + 1);
+ if (o->chan->cid.cid_ani)
+ strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1);
else
ast_log(LOG_WARNING, "Out of memory\n");
}
- if (o->chan->rdnis)
- free(o->chan->rdnis);
+ if (o->chan->cid.cid_rdnis)
+ free(o->chan->cid.cid_rdnis);
if (!ast_strlen_zero(in->macroexten))
- o->chan->rdnis = strdup(in->macroexten);
+ o->chan->cid.cid_rdnis = strdup(in->macroexten);
else
- o->chan->rdnis = strdup(in->exten);
+ o->chan->cid.cid_rdnis = strdup(in->exten);
if (ast_call(o->chan, tmpchan, 0)) {
ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan);
o->stillgoing = 0;
@@ -429,7 +436,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
char restofit[AST_MAX_EXTENSION];
char *transfer = NULL;
char *newnum;
- char callerid[256] = "", *l, *n;
+ char *l;
char *url=NULL; /* JDG */
struct ast_var_t *current;
struct varshead *headp, *newheadp;
@@ -668,14 +675,8 @@ static int dial_exec(struct ast_channel *chan, void *data)
strncpy(privdb, chan->exten, sizeof(privdb) - 1);
}
if (privacy) {
- if (chan->callerid)
- strncpy(callerid, chan->callerid, sizeof(callerid) - 1);
- else
- callerid[0] = '\0';
- ast_callerid_parse(callerid, &n, &l);
- if (l) {
- ast_shrink_phone_number(l);
- } else
+ l = chan->cid.cid_num;
+ if (!l)
l = "";
ast_log(LOG_NOTICE, "Privacy DB is '%s', privacy is %d, clid is '%s'\n", privdb, privacy, l);
}
@@ -797,28 +798,31 @@ static int dial_exec(struct ast_channel *chan, void *data)
tmp->chan->appl = "AppDial";
tmp->chan->data = "(Outgoing Line)";
tmp->chan->whentohangup = 0;
- if (tmp->chan->callerid)
- free(tmp->chan->callerid);
- if (tmp->chan->ani)
- free(tmp->chan->ani);
- if (chan->callerid)
- tmp->chan->callerid = strdup(chan->callerid);
- else
- tmp->chan->callerid = NULL;
+ if (tmp->chan->cid.cid_num)
+ free(tmp->chan->cid.cid_num);
+ tmp->chan->cid.cid_num = NULL;
+ if (tmp->chan->cid.cid_name)
+ free(tmp->chan->cid.cid_name);
+ tmp->chan->cid.cid_name = NULL;
+ if (tmp->chan->cid.cid_ani)
+ free(tmp->chan->cid.cid_ani);
+ tmp->chan->cid.cid_ani = NULL;
+
+ if (chan->cid.cid_num)
+ tmp->chan->cid.cid_num = strdup(chan->cid.cid_num);
+ if (chan->cid.cid_name)
+ tmp->chan->cid.cid_name = strdup(chan->cid.cid_name);
+ if (chan->cid.cid_ani)
+ tmp->chan->cid.cid_ani = strdup(chan->cid.cid_ani);
+
/* Copy language from incoming to outgoing */
strncpy(tmp->chan->language, chan->language, sizeof(tmp->chan->language) - 1);
strncpy(tmp->chan->accountcode, chan->accountcode, sizeof(tmp->chan->accountcode) - 1);
tmp->chan->cdrflags = chan->cdrflags;
if (ast_strlen_zero(tmp->chan->musicclass))
strncpy(tmp->chan->musicclass, chan->musicclass, sizeof(tmp->chan->musicclass) - 1);
- if (chan->ani)
- tmp->chan->ani = strdup(chan->ani);
- else
- tmp->chan->ani = NULL;
- /* Pass hidecallerid setting */
- tmp->chan->restrictcid = chan->restrictcid;
/* Pass callingpres setting */
- tmp->chan->callingpres = chan->callingpres;
+ tmp->chan->cid.cid_pres = chan->cid.cid_pres;
/* Presense of ADSI CPE on outgoing channel follows ours */
tmp->chan->adsicpe = chan->adsicpe;
/* pass the digital flag */
diff --git a/apps/app_directory.c b/apps/app_directory.c
index e0a962f70..306c67c08 100755
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -3,9 +3,9 @@
*
* Provide a directory of extensions
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -176,7 +176,7 @@ static int play_mailbox_owner(struct ast_channel *chan, char *context, char *dia
case '1':
/* Name selected */
loop = 0;
- if (ast_exists_extension(chan,dialcontext,ext,1,chan->callerid)) {
+ if (ast_exists_extension(chan,dialcontext,ext,1,chan->cid.cid_num)) {
strncpy(chan->exten, ext, sizeof(chan->exten)-1);
chan->priority = 0;
strncpy(chan->context, dialcontext, sizeof(chan->context)-1);
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 03f13c67c..6d1964990 100755
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -3,7 +3,7 @@
*
* DISA -- Direct Inward System Access Application 6/20/2001
*
- * Copyright (C) 2001, Linux Support Services, Inc.
+ * Copyright (C) 2001-2004, Digium, Inc.
*
* Jim Dixon <jim@lambdatel.com>
*
@@ -293,20 +293,20 @@ static int disa_exec(struct ast_channel *chan, void *data)
}
/* if can do some more, do it */
- if (!ast_matchmore_extension(chan,ourcontext,exten,1, chan->callerid)) {
+ if (!ast_matchmore_extension(chan,ourcontext,exten,1, chan->cid.cid_num)) {
break;
}
}
}
- if (k && ast_exists_extension(chan,ourcontext,exten,1, chan->callerid))
+ if (k && ast_exists_extension(chan,ourcontext,exten,1, chan->cid.cid_num))
{
ast_playtones_stop(chan);
/* We're authenticated and have a valid extension */
if (ourcallerid && *ourcallerid)
{
- if (chan->callerid) free(chan->callerid);
- chan->callerid = strdup(ourcallerid);
+ if (chan->cid.cid_num) free(chan->cid.cid_num);
+ chan->cid.cid_num = strdup(ourcallerid);
}
strncpy(chan->exten, exten, sizeof(chan->exten) - 1);
strncpy(chan->context, ourcontext, sizeof(chan->context) - 1);
diff --git a/apps/app_enumlookup.c b/apps/app_enumlookup.c
index d2ea84c29..76593b917 100755
--- a/apps/app_enumlookup.c
+++ b/apps/app_enumlookup.c
@@ -3,9 +3,9 @@
*
* Time of day - Report the time of day
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -121,7 +121,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
*t = 0;
pbx_builtin_setvar_helper(chan, "ENUM", tmp);
ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp);
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 51, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 51, chan->cid.cid_num))
chan->priority += 50;
else
res = 0;
@@ -133,7 +133,7 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
} else if (res > 0)
res = 0;
diff --git a/apps/app_groupcount.c b/apps/app_groupcount.c
index 7835d580e..18838be23 100755
--- a/apps/app_groupcount.c
+++ b/apps/app_groupcount.c
@@ -174,7 +174,7 @@ static int group_check_exec(struct ast_channel *chan, void *data)
count = group_get_count(pbx_builtin_getvar_helper(chan, ret), ret);
if (count > max) {
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
else
res = -1;
diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c
index 733a65ec8..ab6fbad1d 100755
--- a/apps/app_hasnewvoicemail.c
+++ b/apps/app_hasnewvoicemail.c
@@ -119,7 +119,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
if (vmcount > 0) {
/* Branch to the next extension */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
} else
ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
diff --git a/apps/app_image.c b/apps/app_image.c
index 04af0a315..3665a0fef 100755
--- a/apps/app_image.c
+++ b/apps/app_image.c
@@ -3,9 +3,9 @@
*
* App to transmit an image
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -51,7 +51,7 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (!ast_supports_images(chan)) {
/* Does not support transport */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
return 0;
}
diff --git a/apps/app_lookupblacklist.c b/apps/app_lookupblacklist.c
index 69743e377..82a556b15 100755
--- a/apps/app_lookupblacklist.c
+++ b/apps/app_lookupblacklist.c
@@ -3,9 +3,9 @@
*
* App to lookup the callerid number, and see if it is blacklisted
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -48,38 +48,30 @@ LOCAL_USER_DECL;
static int
lookupblacklist_exec (struct ast_channel *chan, void *data)
{
- char old_cid[144] = "", *num, *name;
char blacklist[1];
- char shrunknum[64] = "";
struct localuser *u;
int bl = 0;
LOCAL_USER_ADD (u);
- if (chan->callerid)
+ if (chan->cid.cid_num)
{
- strncpy (old_cid, chan->callerid, sizeof (old_cid) - 1);
- ast_callerid_parse (old_cid, &name, &num);
- if (num)
- strncpy (shrunknum, num, sizeof (shrunknum) - 1);
- else
- num = shrunknum;
-
- ast_shrink_phone_number (shrunknum);
- if (!ast_db_get ("blacklist", shrunknum, blacklist, sizeof (blacklist)))
+ if (!ast_db_get ("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
{
if (option_verbose > 2)
- ast_log(LOG_NOTICE, "Blacklisted number %s found\n",shrunknum);
+ ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num);
bl = 1;
}
- else if (!ast_db_get ("blacklist", name, blacklist, sizeof (blacklist)))
+ }
+ if (chan->cid.cid_name) {
+ if (!ast_db_get ("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
{
if (option_verbose > 2)
- ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",name);
+ ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name);
bl = 1;
}
}
- if (bl && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (bl && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
LOCAL_USER_REMOVE (u);
return 0;
diff --git a/apps/app_lookupcidname.c b/apps/app_lookupcidname.c
index ecb0a4e5c..aac3191fe 100755
--- a/apps/app_lookupcidname.c
+++ b/apps/app_lookupcidname.c
@@ -3,9 +3,9 @@
*
* App to set callerid name from database, based on directory number
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -46,32 +46,19 @@ LOCAL_USER_DECL;
static int
lookupcidname_exec (struct ast_channel *chan, void *data)
{
- char old_cid[144] = "", *num, *name;
- char new_cid[144];
char dbname[64];
char shrunknum[64] = "";
struct localuser *u;
LOCAL_USER_ADD (u);
- if (chan->callerid)
- {
- strncpy (old_cid, chan->callerid, sizeof (old_cid) - 1);
- ast_callerid_parse (old_cid, &name, &num); /* this destroys the original string */
- if (num) /* It's possible to get an empty number */
- strncpy (shrunknum, num, sizeof (shrunknum) - 1);
- else
- num = shrunknum;
- ast_shrink_phone_number (shrunknum);
- if (!ast_db_get ("cidname", shrunknum, dbname, sizeof (dbname)))
- {
- snprintf (new_cid, sizeof (new_cid), "\"%s\" <%s>", dbname, num);
- ast_set_callerid (chan, new_cid, 0);
- if (option_verbose > 2)
- ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",
- new_cid);
+ if (chan->cid.cid_num) {
+ if (!ast_db_get ("cidname", shrunknum, dbname, sizeof (dbname))) {
+ ast_set_callerid (chan, NULL, dbname, NULL);
+ if (option_verbose > 2)
+ ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID name to %s\n",
+ dbname);
}
-
- }
+ }
LOCAL_USER_REMOVE (u);
return 0;
}
diff --git a/apps/app_macro.c b/apps/app_macro.c
index ea6775c90..dd658689d 100755
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -3,7 +3,7 @@
*
* Macro Implementation
*
- * Copyright (C) 2003, Digium
+ * Copyright (C) 2003-2004, Digium, Inc.
*
* Mark Spencer <markster@digium.com>
*
@@ -85,7 +85,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
return 0;
}
snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro);
- if (!ast_exists_extension(chan, fullmacro, "s", 1, chan->callerid)) {
+ if (!ast_exists_extension(chan, fullmacro, "s", 1, chan->cid.cid_num)) {
if (!ast_context_find(fullmacro))
ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
else
@@ -137,8 +137,8 @@ static int macro_exec(struct ast_channel *chan, void *data)
pbx_builtin_setvar_helper(chan, varname, cur);
argc++;
}
- while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
- if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) {
+ while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
+ if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num))) {
/* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
/* Just return result as to the previous application as if it had been dialed */
@@ -210,7 +210,7 @@ out:
/* Handle macro offset if it's set by checking the availability of step n + offset + 1, otherwise continue
normally if there is any problem */
if (sscanf(offsets, "%d", &offset) == 1) {
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + offset + 1, chan->cid.cid_num)) {
chan->priority += offset;
}
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index ef2ff3de9..e9630d0a6 100755
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -821,7 +821,7 @@ zapretry:
char tmp[2];
tmp[0] = f->subclass;
tmp[1] = '\0';
- if (ast_exists_extension(chan, exitcontext, tmp, 1, chan->callerid)) {
+ if (ast_exists_extension(chan, exitcontext, tmp, 1, chan->cid.cid_num)) {
strncpy(chan->context, exitcontext, sizeof(chan->context) - 1);
strncpy(chan->exten, tmp, sizeof(chan->exten) - 1);
chan->priority = 0;
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 55216d4eb..4110d740b 100755
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -1,11 +1,11 @@
/*
* Asterisk -- A telephony toolkit for Linux.
*
- * Time of day - Report the time of day
+ * Open Settlement Protocol Lookup
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -110,7 +110,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
}
LOCAL_USER_ADD(u);
ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", temp, provider ? provider : "<default>");
- if ((res = ast_osp_lookup(chan, provider, temp, chan->callerid, &result)) > 0) {
+ if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) {
char tmp[80];
snprintf(tmp, sizeof(tmp), "%d", result.handle);
pbx_builtin_setvar_helper(chan, "OSPHANDLE", tmp);
@@ -127,7 +127,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
} else if (res > 0)
res = 0;
@@ -171,7 +171,7 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
} else if (res > 0)
res = 0;
@@ -218,7 +218,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
} else if (res > 0)
res = 0;
diff --git a/apps/app_parkandannounce.c b/apps/app_parkandannounce.c
index c3f949ec3..269ee1fde 100755
--- a/apps/app_parkandannounce.c
+++ b/apps/app_parkandannounce.c
@@ -6,9 +6,9 @@
* With TONS of help from Mark!
*
* Asterisk is Copyrighted as follows
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -142,8 +142,8 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
if(option_verbose > 2) {
- ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->callerid);
- if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
+ ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->cid.cid_num);
+ if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
ast_verbose( VERBOSE_PREFIX_3 "Warning: Return Context Invalid, call will return to default|s\n");
}
}
@@ -161,7 +161,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
/* Now place the call to the extention */
- dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->callerid);
+ dchan = ast_request_and_dial(dialtech, AST_FORMAT_SLINEAR, dialstr,30000, &outstate, chan->cid.cid_num, chan->cid.cid_name);
if(dchan) {
if(dchan->_state == AST_STATE_UP) {
diff --git a/apps/app_privacy.c b/apps/app_privacy.c
index 7628ea0e7..2972ee73a 100755
--- a/apps/app_privacy.c
+++ b/apps/app_privacy.c
@@ -3,9 +3,9 @@
*
* Block all calls without Caller*ID, require phone # to be entered
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -62,7 +62,7 @@ privacy_exec (struct ast_channel *chan, void *data)
struct ast_config *cfg;
LOCAL_USER_ADD (u);
- if (chan->callerid)
+ if (chan->cid.cid_num)
{
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "CallerID Present: Skipping\n");
@@ -118,13 +118,12 @@ privacy_exec (struct ast_channel *chan, void *data)
res = ast_streamfile(chan, "privacy-thankyou", chan->language);
if (!res)
res = ast_waitstream(chan, "");
- snprintf (new_cid, sizeof (new_cid), "\"%s\" <%s>", "Privacy Manager", phone);
- ast_set_callerid (chan, new_cid, 0);
+ ast_set_callerid (chan, phone, "Privacy Manager", NULL);
if (option_verbose > 2)
ast_verbose (VERBOSE_PREFIX_3 "Changed Caller*ID to %s\n",new_cid);
} else {
/*Send the call to n+101 priority, where n is the current priority*/
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
}
if (cfg)
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 6e1528b0c..daea410be 100755
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -3,9 +3,9 @@
*
* True call queues with optional send URL on answer
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* 2004-06-04: Priorities in queues added by inAccess Networks (work funded by Hellas On Line (HOL) www.hol.gr).
*
@@ -318,8 +318,11 @@ static int join_queue(char *queuename, struct queue_ent *qe)
q->count++;
res = 0;
manager_event(EVENT_FLAG_CALL, "Join",
- "Channel: %s\r\nCallerID: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\n",
- qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : "unknown"), q->name, qe->pos, q->count );
+ "Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\n",
+ qe->chan->name,
+ qe->chan->cid.cid_num ? qe->chan->cid.cid_num : "unknown",
+ qe->chan->cid.cid_name ? qe->chan->cid.cid_name : "unknown",
+ q->name, qe->pos, q->count );
#if 0
ast_log(LOG_NOTICE, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos );
#endif
@@ -569,18 +572,21 @@ static int ring_entry(struct queue_ent *qe, struct localuser *tmp)
tmp->chan->appl = "AppQueue";
tmp->chan->data = "(Outgoing Line)";
tmp->chan->whentohangup = 0;
- if (tmp->chan->callerid)
- free(tmp->chan->callerid);
- if (tmp->chan->ani)
- free(tmp->chan->ani);
- if (qe->chan->callerid)
- tmp->chan->callerid = strdup(qe->chan->callerid);
- else
- tmp->chan->callerid = NULL;
- if (qe->chan->ani)
- tmp->chan->ani = strdup(qe->chan->ani);
- else
- tmp->chan->ani = NULL;
+ if (tmp->chan->cid.cid_num)
+ free(tmp->chan->cid.cid_num);
+ tmp->chan->cid.cid_num = NULL;
+ if (tmp->chan->cid.cid_name)
+ free(tmp->chan->cid.cid_name);
+ tmp->chan->cid.cid_name = NULL;
+ if (tmp->chan->cid.cid_ani)
+ free(tmp->chan->cid.cid_ani);
+ tmp->chan->cid.cid_ani = NULL;
+ if (qe->chan->cid.cid_num)
+ tmp->chan->cid.cid_num = strdup(qe->chan->cid.cid_num);
+ if (qe->chan->cid.cid_name)
+ tmp->chan->cid.cid_name = strdup(qe->chan->cid.cid_name);
+ if (qe->chan->cid.cid_ani)
+ tmp->chan->cid.cid_ani = strdup(qe->chan->cid.cid_ani);
/* Presense of ADSI CPE on outgoing channel follows ours */
tmp->chan->adsicpe = qe->chan->adsicpe;
/* Place the call, but don't wait on the answer */
@@ -601,11 +607,13 @@ static int ring_entry(struct queue_ent *qe, struct localuser *tmp)
"AgentCalled: %s/%s\r\n"
"ChannelCalling: %s\r\n"
"CallerID: %s\r\n"
+ "CallerIDName: %s\r\n"
"Context: %s\r\n"
"Extension: %s\r\n"
"Priority: %d\r\n",
tmp->tech, tmp->numsubst, qe->chan->name,
- tmp->chan->callerid ? tmp->chan->callerid : "unknown <>",
+ tmp->chan->cid.cid_num ? tmp->chan->cid.cid_num : "unknown",
+ tmp->chan->cid.cid_name ? tmp->chan->cid.cid_name : "unknown",
qe->chan->context, qe->chan->exten, qe->chan->priority);
}
if (option_verbose > 2)
@@ -700,7 +708,7 @@ static int valid_exit(struct queue_ent *qe, char digit)
return 0;
tmp[0] = digit;
tmp[1] = '\0';
- if (ast_exists_extension(qe->chan, qe->context, tmp, 1, qe->chan->callerid)) {
+ if (ast_exists_extension(qe->chan, qe->context, tmp, 1, qe->chan->cid.cid_num)) {
strncpy(qe->chan->context, qe->context, sizeof(qe->chan->context) - 1);
strncpy(qe->chan->exten, tmp, sizeof(qe->chan->exten) - 1);
qe->chan->priority = 0;
@@ -1410,7 +1418,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
break;
case RES_EXISTS:
ast_log(LOG_WARNING, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename);
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
}
res = 0;
@@ -1487,7 +1495,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
break;
case RES_EXISTS:
ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", interface, queuename);
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
}
res = 0;
@@ -1598,7 +1606,7 @@ static int queue_exec(struct ast_channel *chan, void *data)
qe.last_pos_said = 0;
qe.last_pos = 0;
if (!join_queue(queuename, &qe)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", url ? url : "", chan->callerid ? chan->callerid : "");
+ ast_queue_log(queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", url ? url : "", chan->cid.cid_num ? chan->cid.cid_num : "");
/* Start music on hold */
check_turns:
if (ringing) {
@@ -2108,10 +2116,14 @@ static int manager_queues_status( struct mansession *s, struct message *m )
"Position: %d\r\n"
"Channel: %s\r\n"
"CallerID: %s\r\n"
+ "CallerIDName: %s\r\n"
"Wait: %ld\r\n"
"%s"
"\r\n",
- q->name, pos++, qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : ""), (long)(now - qe->start), idText);
+ q->name, pos++, qe->chan->name,
+ qe->chan->cid.cid_num ? qe->chan->cid.cid_num : "unknown",
+ qe->chan->cid.cid_name ? qe->chan->cid.cid_name : "unknown",
+ (long)(now - qe->start), idText);
ast_mutex_unlock(&s->lock);
ast_mutex_unlock(&q->lock);
}
diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c
index 73d24a189..b8f537fa9 100755
--- a/apps/app_sendtext.c
+++ b/apps/app_sendtext.c
@@ -3,9 +3,9 @@
*
* App to transmit a text message
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -54,7 +54,7 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
if (!chan->pvt->send_text) {
ast_mutex_unlock(&chan->lock);
/* Does not support transport */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
LOCAL_USER_REMOVE(u);
return 0;
diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c
index 069c2af98..100fb813c 100755
--- a/apps/app_setcallerid.c
+++ b/apps/app_setcallerid.c
@@ -89,7 +89,7 @@ static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
return 0;
}
LOCAL_USER_ADD(u);
- chan->callingpres = pres;
+ chan->cid.cid_pres = pres;
LOCAL_USER_REMOVE(u);
return res;
}
@@ -110,6 +110,8 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
{
int res = 0;
char tmp[256] = "";
+ char name[256];
+ char num[256];
struct localuser *u;
char *opt;
int anitoo = 0;
@@ -123,7 +125,8 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
anitoo = 1;
}
LOCAL_USER_ADD(u);
- ast_set_callerid(chan, strlen(tmp) ? tmp : NULL, anitoo);
+ ast_callerid_split(tmp, name, sizeof(name), num, sizeof(num));
+ ast_set_callerid(chan, num, name, anitoo ? num : NULL);
LOCAL_USER_REMOVE(u);
return res;
}
diff --git a/apps/app_setcidname.c b/apps/app_setcidname.c
index ee430911b..44b9dbd04 100755
--- a/apps/app_setcidname.c
+++ b/apps/app_setcidname.c
@@ -34,7 +34,7 @@ static char *descrip =
" SetCIDName(cname[|a]): Set Caller*ID Name on a call to a new\n"
"value, while preserving the original Caller*ID number. This is\n"
"useful for providing additional information to the called\n"
-"party. Sets ANI as well if a flag is used. Always returns 0\n";
+"party. Always returns 0\n";
STANDARD_LOCAL_USER;
@@ -44,36 +44,16 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
{
int res = 0;
char tmp[256] = "";
- char oldcid[256] = "", *l, *n;
- char newcid[256] = "";
struct localuser *u;
char *opt;
- int anitoo = 0;
if (data)
strncpy(tmp, (char *)data, sizeof(tmp) - 1);
opt = strchr(tmp, '|');
if (opt) {
*opt = '\0';
- opt++;
- if (*opt == 'a')
- anitoo = 1;
}
LOCAL_USER_ADD(u);
- if (chan->callerid) {
- strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1);
- ast_callerid_parse(oldcid, &n, &l);
- n = tmp;
- if (!ast_strlen_zero(n)) {
- if (l && !ast_strlen_zero(l))
- snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l);
- else
- strncpy(newcid, tmp, sizeof(newcid) - 1);
- } else if (l && !ast_strlen_zero(l)) {
- strncpy(newcid, l, sizeof(newcid) - 1);
- }
- } else
- strncpy(newcid, tmp, sizeof(newcid) - 1);
- ast_set_callerid(chan, !ast_strlen_zero(newcid) ? newcid : NULL, anitoo);
+ ast_set_callerid(chan, NULL, tmp, NULL);
LOCAL_USER_REMOVE(u);
return res;
}
diff --git a/apps/app_setcidnum.c b/apps/app_setcidnum.c
index b96330ec5..1c9d0003d 100755
--- a/apps/app_setcidnum.c
+++ b/apps/app_setcidnum.c
@@ -3,9 +3,9 @@
*
* App to set callerid
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
* Oliver Daudey <traveler@xs4all.nl>
*
* This program is free software, distributed under the terms of
@@ -44,12 +44,10 @@ LOCAL_USER_DECL;
static int setcallerid_exec(struct ast_channel *chan, void *data)
{
int res = 0;
- char tmp[256] = "";
- char oldcid[256] = "", *l, *n;
- char newcid[256] = "";
struct localuser *u;
char *opt;
int anitoo = 0;
+ char tmp[256];
if (data)
strncpy(tmp, (char *)data, sizeof(tmp) - 1);
opt = strchr(tmp, '|');
@@ -60,21 +58,7 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
anitoo = 1;
}
LOCAL_USER_ADD(u);
- if (chan->callerid) {
- strncpy(oldcid, chan->callerid, sizeof(oldcid) - 1);
- ast_callerid_parse(oldcid, &n, &l);
- l = tmp;
- if (!ast_strlen_zero(l)) {
- if (n && !ast_strlen_zero(n))
- snprintf(newcid, sizeof(newcid), "\"%s\" <%s>", n, l);
- else
- strncpy(newcid, tmp, sizeof(newcid) - 1);
- } else if (n && !ast_strlen_zero(n)) {
- strncpy(newcid, n, sizeof(newcid) - 1);
- }
- } else
- strncpy(newcid, tmp, sizeof(newcid) - 1);
- ast_set_callerid(chan, !ast_strlen_zero(newcid) ? newcid : NULL, anitoo);
+ ast_set_callerid(chan, tmp, NULL, anitoo ? tmp : NULL);
LOCAL_USER_REMOVE(u);
return res;
}
diff --git a/apps/app_sms.c b/apps/app_sms.c
index a7b55bd46..3a4d5392e 100755
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1050,17 +1050,8 @@ sms_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (chan->callerid) {
- /* get caller ID. Used as originating address on sc side receives */
- char temp[256], *name, *num;
- strncpy (temp, chan->callerid, sizeof(temp) - 1);
- ast_callerid_parse (temp, &name, &num);
- if (!num)
- num = temp;
- ast_shrink_phone_number (num);
- if (strlen (num) < sizeof (h.cli))
- strncpy(h.cli, num, sizeof(h.cli) - 1);
- }
+ if (chan->cid.cid_num)
+ strncpy(h.cli, chan->cid.cid_num, sizeof(h.cli) - 1);
{
char *d = data, *p, answer = 0;
diff --git a/apps/app_system.c b/apps/app_system.c
index 89bddc3e3..d494b9eff 100755
--- a/apps/app_system.c
+++ b/apps/app_system.c
@@ -72,7 +72,7 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
} else {
if (res < 0)
res = 0;
- if (res && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (res && ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
res = 0;
}
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 0816949af..5d15d94d8 100755
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -124,7 +124,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
char t[2];
t[0] = fr->subclass;
t[1] = '\0';
- if (ast_canmatch_extension(chan, chan->context, t, 1, chan->callerid)) {
+ if (ast_canmatch_extension(chan, chan->context, t, 1, chan->cid.cid_num)) {
/* They entered a valid extension, or might be anyhow */
res = fr->subclass;
ast_frfree(fr);
@@ -146,7 +146,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
ms = 0;
if ((ms > min) && ((max < 0) || (ms < max))) {
ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
- if (ast_exists_extension(chan, chan->context, "talk", 1, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, "talk", 1, chan->cid.cid_num)) {
strncpy(chan->exten, "talk", sizeof(chan->exten) -1 );
chan->priority = 0;
}
diff --git a/apps/app_transfer.c b/apps/app_transfer.c
index 826c93c05..31464372e 100755
--- a/apps/app_transfer.c
+++ b/apps/app_transfer.c
@@ -3,9 +3,9 @@
*
* Transfer a caller
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -53,7 +53,7 @@ static int transfer_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
}
if (res > 0)
diff --git a/apps/app_txtcidname.c b/apps/app_txtcidname.c
index 418f15801..e9fc107fa 100755
--- a/apps/app_txtcidname.c
+++ b/apps/app_txtcidname.c
@@ -75,7 +75,7 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
}
if (!res) {
/* Look for a "busy" place */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
} else if (res > 0)
res = 0;
diff --git a/apps/app_url.c b/apps/app_url.c
index fdaa270ea..a1ea624d3 100755
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -3,9 +3,9 @@
*
* App to transmit a URL
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -65,7 +65,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (!ast_channel_supports_html(chan)) {
/* Does not support transport */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
LOCAL_USER_REMOVE(u);
return 0;
@@ -92,7 +92,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
break;
case AST_HTML_NOSUPPORT:
/* Does not support transport */
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority += 100;
res = 0;
goto out;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index fef41ac74..94ecb6025 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -830,19 +830,22 @@ static int base_encode(char *filename, FILE *so)
return 1;
}
-static void prep_email_sub_vars(struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *mailbox, char *callerid, char *dur, char *date, char *passdata, size_t passdatasize)
+static void prep_email_sub_vars(struct ast_channel *ast, struct ast_vm_user *vmu, int msgnum, char *mailbox, char *cidnum, char *cidname, char *dur, char *date, char *passdata, size_t passdatasize)
{
+ char callerid[256];
/* Prepare variables for substition in email body and subject */
pbx_builtin_setvar_helper(ast, "VM_NAME", vmu->fullname);
pbx_builtin_setvar_helper(ast, "VM_DUR", dur);
snprintf(passdata, passdatasize, "%d", msgnum);
pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata);
pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox);
- pbx_builtin_setvar_helper(ast, "VM_CALLERID", (callerid ? callerid : "an unknown caller"));
+ pbx_builtin_setvar_helper(ast, "VM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum));
+ pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (cidname ? cidname : "an unknown caller"));
+ pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (cidnum ? cidnum : "an unknown caller"));
pbx_builtin_setvar_helper(ast, "VM_DATE", date);
}
-static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *mailbox, char *callerid, char *attach, char *format, int duration, int attach_user_voicemail)
+static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail)
{
FILE *p=NULL;
int pfd;
@@ -912,7 +915,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
int vmlen = strlen(fromstring)*3 + 200;
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
- prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,callerid,dur,date,passdata, vmlen);
+ prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
pbx_substitute_variables_helper(ast,fromstring,passdata,vmlen);
fprintf(p, "From: %s <%s>\n",passdata,who);
} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
@@ -929,7 +932,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
int vmlen = strlen(emailsubject)*3 + 200;
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
- prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,callerid,dur,date,passdata, vmlen);
+ prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
pbx_substitute_variables_helper(ast,emailsubject,passdata,vmlen);
fprintf(p, "Subject: %s\n",passdata);
} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
@@ -965,7 +968,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
int vmlen = strlen(emailbody)*3 + 200;
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
- prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,callerid,dur,date,passdata, vmlen);
+ prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
pbx_substitute_variables_helper(ast,emailbody,passdata,vmlen);
fprintf(p, "%s\n",passdata);
} else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n");
@@ -976,7 +979,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
"in mailbox %s from %s, on %s so you might\n"
"want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname,
- dur, msgnum + 1, mailbox, (callerid ? callerid : "an unknown caller"), date);
+ dur, msgnum + 1, mailbox, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date);
}
if (attach_user_voicemail) {
fprintf(p, "--%s\n", bound);
@@ -1000,7 +1003,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *m
return 0;
}
-static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char *callerid, int duration, struct ast_vm_user *vmu)
+static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char *cidnum, char *cidname, int duration, struct ast_vm_user *vmu)
{
FILE *p=NULL;
int pfd;
@@ -1062,7 +1065,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
int vmlen = strlen(fromstring)*3 + 200;
if ((passdata = alloca(vmlen))) {
memset(passdata, 0, vmlen);
- prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,callerid,dur,date,passdata, vmlen);
+ prep_email_sub_vars(ast,vmu,msgnum + 1,mailbox,cidnum, cidname,dur,date,passdata, vmlen);
pbx_substitute_variables_helper(ast,pagerfromstring,passdata,vmlen);
fprintf(p, "From: %s <%s>\n",passdata,who);
} else
@@ -1075,7 +1078,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *mailbox, char
fprintf(p, "Subject: New VM\n\n");
strftime(date, sizeof(date), "%A, %B %d, %Y at %r", &tm);
fprintf(p, "New %s long msg in box %s\n"
- "from %s, on %s", dur, mailbox, (callerid ? callerid : "unknown"), date);
+ "from %s, on %s", dur, mailbox, (cidname ? cidname : (cidnum ? cidnum : "unknown")), date);
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
@@ -1218,7 +1221,7 @@ static int copy(char *infile, char *outfile)
#endif
}
-static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *callerid);
+static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname);
static void copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int imbox, int msgnum, long duration, struct ast_vm_user *recip, char *fmt)
{
@@ -1259,7 +1262,7 @@ static void copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int
ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
}
- notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->callerid);
+ notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
}
static void run_externnotify(char *context, char *extension)
@@ -1282,6 +1285,7 @@ static void run_externnotify(char *context, char *extension)
static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int busy, int unavail)
{
char txtfile[256];
+ char callerid[256];
FILE *txt;
int res = 0;
int msgnum;
@@ -1341,21 +1345,21 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
/* Check current or macro-calling context for special extensions */
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->callerid))
+ if (ast_exists_extension(chan, vmu->exit, "o", 1, chan->cid.cid_num))
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->callerid))
+ } else if (ast_exists_extension(chan, chan->context, "o", 1, chan->cid.cid_num))
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
- else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->callerid)) {
+ else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "o", 1, chan->cid.cid_num)) {
strncat(ecodes, "0", sizeof(ecodes) - strlen(ecodes) - 1);
ousemacro = 1;
}
if (!ast_strlen_zero(vmu->exit)) {
- if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->callerid))
+ if (ast_exists_extension(chan, vmu->exit, "a", 1, chan->cid.cid_num))
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->callerid))
+ } else if (ast_exists_extension(chan, chan->context, "a", 1, chan->cid.cid_num))
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
- else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->callerid)) {
+ else if (!ast_strlen_zero(chan->macrocontext) && ast_exists_extension(chan, chan->macrocontext, "a", 1, chan->cid.cid_num)) {
strncat(ecodes, "*", sizeof(ecodes) - strlen(ecodes) - 1);
ausemacro = 1;
}
@@ -1463,7 +1467,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
chan->exten,
chan->priority,
chan->name,
- chan->callerid ? chan->callerid : "Unknown",
+ ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num),
date, (long)time(NULL));
fclose(txt);
} else
@@ -1505,7 +1509,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
free_user(recip);
}
}
- notify_new_message(chan, vmu, msgnum, duration, fmt, chan->callerid);
+ notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
} else {
res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
if (!res)
@@ -1519,7 +1523,7 @@ leave_vm_out:
} else {
ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext);
/*Send the call to n+101 priority, where n is the current priority*/
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid))
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
chan->priority+=100;
}
@@ -2158,7 +2162,7 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu,
return cmd;
}
-static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *callerid)
+static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname)
{
char todir[256], fn[256], ext_context[256], *stringp;
@@ -2179,14 +2183,14 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
attach_user_voicemail = vmu->attach;
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
- sendmail(myserveremail, vmu, msgnum, vmu->mailbox, callerid, fn, fmt, duration, attach_user_voicemail);
+ sendmail(myserveremail, vmu, msgnum, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail);
}
if (!ast_strlen_zero(vmu->pager)) {
char *myserveremail = serveremail;
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
- sendpage(myserveremail, vmu->pager, msgnum, vmu->mailbox, callerid, duration, vmu);
+ sendpage(myserveremail, vmu->pager, msgnum, vmu->mailbox, cidnum, cidname, duration, vmu);
}
} else {
ast_log(LOG_ERROR, "Out of memory\n");
@@ -2312,14 +2316,14 @@ static int forward_message(struct ast_channel *chan, char *context, char *dir, i
attach_user_voicemail = vmtmp->attach;
if (!ast_strlen_zero(vmtmp->serveremail))
myserveremail = vmtmp->serveremail;
- sendmail(myserveremail, vmtmp, todircount, vmtmp->mailbox, callerid, fn, tmp, duration, attach_user_voicemail);
+ sendmail(myserveremail, vmtmp, todircount, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, fn, tmp, duration, attach_user_voicemail);
}
if (!ast_strlen_zero(vmtmp->pager)) {
char *myserveremail = serveremail;
if (!ast_strlen_zero(vmtmp->serveremail))
myserveremail = vmtmp->serveremail;
- sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->mailbox, callerid, duration, vmtmp);
+ sendpage(myserveremail, vmtmp->pager, todircount, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, duration, vmtmp);
}
ast_destroy(mif); /* or here */
@@ -3177,7 +3181,6 @@ static int vm_execmain(struct ast_channel *chan, void *data)
struct ast_vm_user *vmu = NULL, vmus;
char *context=NULL;
int silentexit = 0;
- char cid[256]="";
char *passptr;
LOCAL_USER_ADD(u);
@@ -3239,21 +3242,14 @@ static int vm_execmain(struct ast_channel *chan, void *data)
goto out;
}
if (ast_strlen_zero(vms.username)) {
- char *callerid=NULL, *name=NULL;
- if(chan->callerid != NULL) {
- strncpy(cid, chan->callerid, sizeof(cid) - 1);
- ast_callerid_parse(cid, &name, &callerid);
- }
- if(callerid != NULL) {
- if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_3 "No username but # key pressed. Using CID '%s'\n",callerid);
- strncpy(vms.username, callerid, sizeof(vms.username) - 1);
- } else {
- if (option_verbose > 2)
+ if (chan->cid.cid_num) {
+ strncpy(vms.username, chan->cid.cid_num, sizeof(vms.username) - 1);
+ } else {
+ if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Username not entered\n");
- res = 0;
- goto out;
- }
+ res = 0;
+ goto out;
+ }
}
if (useadsi)
adsi_password(chan);
@@ -3746,7 +3742,7 @@ static int vm_box_exists(struct ast_channel *chan, void *data) {
}
if (find_user(&svm, context, box)) {
- if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->callerid)) {
+ if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num)) {
chan->priority += 100;
} else
ast_log(LOG_WARNING, "VM box %s@%s exists, but extension %s, priority %d doesn't exist\n", box, context, chan->exten, chan->priority + 101);
diff --git a/apps/app_zapateller.c b/apps/app_zapateller.c
index 42777779c..8c6183b82 100755
--- a/apps/app_zapateller.c
+++ b/apps/app_zapateller.c
@@ -3,9 +3,9 @@
*
* Playback the special information tone to get rid of telemarketers
*
- * Copyright (C) 1999, Mark Spencer
+ * Copyright (C) 1999-2004, Digium, Inc.
*
- * Mark Spencer <markster@linux-support.net>
+ * Mark Spencer <markster@digium.com>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
@@ -70,7 +70,7 @@ static int zapateller_exec(struct ast_channel *chan, void *data)
res = ast_safe_sleep(chan, 500);
}
}
- if (chan->callerid && nocallerid) {
+ if (chan->cid.cid_num && nocallerid) {
LOCAL_USER_REMOVE(u);
return res;
}