mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
Merge 'T' and other dialing enhancements
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1156 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -79,7 +79,8 @@ static char *descrip =
|
|||||||
struct localuser {
|
struct localuser {
|
||||||
struct ast_channel *chan;
|
struct ast_channel *chan;
|
||||||
int stillgoing;
|
int stillgoing;
|
||||||
int allowredirect;
|
int allowredirect_in;
|
||||||
|
int allowredirect_out;
|
||||||
int ringbackonly;
|
int ringbackonly;
|
||||||
int musiconhold;
|
int musiconhold;
|
||||||
int dataquality;
|
int dataquality;
|
||||||
@@ -105,7 +106,7 @@ static void hanguptree(struct localuser *outgoing, struct ast_channel *exception
|
|||||||
|
|
||||||
#define MAX 256
|
#define MAX 256
|
||||||
|
|
||||||
static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir, int *allowdisconnect)
|
static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect)
|
||||||
{
|
{
|
||||||
struct localuser *o;
|
struct localuser *o;
|
||||||
int found;
|
int found;
|
||||||
@@ -182,7 +183,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
||||||
peer = o->chan;
|
peer = o->chan;
|
||||||
*allowredir = o->allowredirect;
|
*allowredir_in = o->allowredirect_in;
|
||||||
|
*allowredir_out = o->allowredirect_out;
|
||||||
*allowdisconnect = o->allowdisconnect;
|
*allowdisconnect = o->allowdisconnect;
|
||||||
}
|
}
|
||||||
} else if (o->chan == winner) {
|
} else if (o->chan == winner) {
|
||||||
@@ -218,7 +220,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
||||||
peer = o->chan;
|
peer = o->chan;
|
||||||
*allowredir = o->allowredirect;
|
*allowredir_in = o->allowredirect_in;
|
||||||
|
*allowredir_out = o->allowredirect_out;
|
||||||
*allowdisconnect = o->allowdisconnect;
|
*allowdisconnect = o->allowdisconnect;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -326,7 +329,8 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
struct localuser *outgoing=NULL, *tmp;
|
struct localuser *outgoing=NULL, *tmp;
|
||||||
struct ast_channel *peer;
|
struct ast_channel *peer;
|
||||||
int to;
|
int to;
|
||||||
int allowredir=0;
|
int allowredir_in=0;
|
||||||
|
int allowredir_out=0;
|
||||||
int allowdisconnect=0;
|
int allowdisconnect=0;
|
||||||
int privacy=0;
|
int privacy=0;
|
||||||
int resetcdr=0;
|
int resetcdr=0;
|
||||||
@@ -447,8 +451,11 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
memset(tmp, 0, sizeof(struct localuser));
|
memset(tmp, 0, sizeof(struct localuser));
|
||||||
if (transfer) {
|
if (transfer) {
|
||||||
if (strchr(transfer, 't'))
|
if (strchr(transfer, 't'))
|
||||||
tmp->allowredirect = 1;
|
tmp->allowredirect_in = 1;
|
||||||
else tmp->allowredirect = 0;
|
else tmp->allowredirect_in = 0;
|
||||||
|
if (strchr(transfer, 'T'))
|
||||||
|
tmp->allowredirect_out = 1;
|
||||||
|
else tmp->allowredirect_out = 0;
|
||||||
if (strchr(transfer, 'r'))
|
if (strchr(transfer, 'r'))
|
||||||
tmp->ringbackonly = 1;
|
tmp->ringbackonly = 1;
|
||||||
else tmp->ringbackonly = 0;
|
else tmp->ringbackonly = 0;
|
||||||
@@ -583,7 +590,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
to = atoi(timeout) * 1000;
|
to = atoi(timeout) * 1000;
|
||||||
else
|
else
|
||||||
to = -1;
|
to = -1;
|
||||||
peer = wait_for_answer(chan, outgoing, &to, &allowredir, &allowdisconnect);
|
peer = wait_for_answer(chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
if (to)
|
if (to)
|
||||||
/* Musta gotten hung up */
|
/* Musta gotten hung up */
|
||||||
@@ -637,13 +644,15 @@ static int dial_exec(struct ast_channel *chan, void *data)
|
|||||||
ast_channel_setoption(chan,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
ast_channel_setoption(chan,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
||||||
ast_channel_setoption(peer,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
ast_channel_setoption(peer,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
||||||
}
|
}
|
||||||
res = ast_bridge_call(chan, peer, allowredir, allowdisconnect | clearchannel);
|
res = ast_bridge_call(chan, peer, allowredir_in, allowredir_out, allowdisconnect | clearchannel);
|
||||||
if (clearchannel)
|
if (clearchannel)
|
||||||
{
|
{
|
||||||
int x = 1;
|
int x = 1;
|
||||||
ast_channel_setoption(chan,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
ast_channel_setoption(chan,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
||||||
ast_channel_setoption(peer,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
ast_channel_setoption(peer,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (res != AST_PBX_NO_HANGUP_PEER)
|
||||||
ast_hangup(peer);
|
ast_hangup(peer);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
@@ -92,7 +92,8 @@ static char *app_rqm_descrip =
|
|||||||
struct localuser {
|
struct localuser {
|
||||||
struct ast_channel *chan;
|
struct ast_channel *chan;
|
||||||
int stillgoing;
|
int stillgoing;
|
||||||
int allowredirect;
|
int allowredirect_in;
|
||||||
|
int allowredirect_out;
|
||||||
int ringbackonly;
|
int ringbackonly;
|
||||||
int musiconhold;
|
int musiconhold;
|
||||||
int dataquality;
|
int dataquality;
|
||||||
@@ -283,7 +284,7 @@ static void hanguptree(struct localuser *outgoing, struct ast_channel *exception
|
|||||||
|
|
||||||
#define MAX 256
|
#define MAX 256
|
||||||
|
|
||||||
static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir, int *allowdisconnect, char *queue)
|
static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, char *queue)
|
||||||
{
|
{
|
||||||
struct localuser *o;
|
struct localuser *o;
|
||||||
int found;
|
int found;
|
||||||
@@ -329,7 +330,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
||||||
peer = o->chan;
|
peer = o->chan;
|
||||||
*allowredir = o->allowredirect;
|
*allowredir_in = o->allowredirect_in;
|
||||||
|
*allowredir_out = o->allowredirect_out;
|
||||||
*allowdisconnect = o->allowdisconnect;
|
*allowdisconnect = o->allowdisconnect;
|
||||||
}
|
}
|
||||||
} else if (o->chan == winner) {
|
} else if (o->chan == winner) {
|
||||||
@@ -343,7 +345,8 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
|
|||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
|
||||||
peer = o->chan;
|
peer = o->chan;
|
||||||
*allowredir = o->allowredirect;
|
*allowredir_in = o->allowredirect_in;
|
||||||
|
*allowredir_out = o->allowredirect_out;
|
||||||
*allowdisconnect = o->allowdisconnect;
|
*allowdisconnect = o->allowdisconnect;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -441,7 +444,8 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
|
|||||||
struct member *cur;
|
struct member *cur;
|
||||||
struct localuser *outgoing=NULL, *tmp = NULL;
|
struct localuser *outgoing=NULL, *tmp = NULL;
|
||||||
int to;
|
int to;
|
||||||
int allowredir=0;
|
int allowredir_in=0;
|
||||||
|
int allowredir_out=0;
|
||||||
int allowdisconnect=0;
|
int allowdisconnect=0;
|
||||||
char numsubst[AST_MAX_EXTENSION];
|
char numsubst[AST_MAX_EXTENSION];
|
||||||
char restofit[AST_MAX_EXTENSION];
|
char restofit[AST_MAX_EXTENSION];
|
||||||
@@ -466,7 +470,9 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
|
|||||||
memset(tmp, 0, sizeof(struct localuser));
|
memset(tmp, 0, sizeof(struct localuser));
|
||||||
if (options) {
|
if (options) {
|
||||||
if (strchr(options, 't'))
|
if (strchr(options, 't'))
|
||||||
tmp->allowredirect = 1;
|
tmp->allowredirect_in = 1;
|
||||||
|
if (strchr(options, 'T'))
|
||||||
|
tmp->allowredirect_out = 1;
|
||||||
if (strchr(options, 'r'))
|
if (strchr(options, 'r'))
|
||||||
tmp->ringbackonly = 1;
|
tmp->ringbackonly = 1;
|
||||||
if (strchr(options, 'm'))
|
if (strchr(options, 'm'))
|
||||||
@@ -568,7 +574,7 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
|
|||||||
to = -1;
|
to = -1;
|
||||||
ast_pthread_mutex_unlock(&qe->parent->lock);
|
ast_pthread_mutex_unlock(&qe->parent->lock);
|
||||||
|
|
||||||
peer = wait_for_answer(qe->chan, outgoing, &to, &allowredir, &allowdisconnect, qe->parent->name);
|
peer = wait_for_answer(qe->chan, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, qe->parent->name);
|
||||||
if (!peer) {
|
if (!peer) {
|
||||||
if (to)
|
if (to)
|
||||||
/* Musta gotten hung up */
|
/* Musta gotten hung up */
|
||||||
@@ -629,8 +635,11 @@ static int try_calling(struct queue_ent *qe, char *options, char *announceoverri
|
|||||||
ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
|
ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url);
|
||||||
ast_channel_sendurl( peer, url );
|
ast_channel_sendurl( peer, url );
|
||||||
} /* /JDG */
|
} /* /JDG */
|
||||||
bridge = ast_bridge_call(qe->chan, peer, allowredir, allowdisconnect);
|
bridge = ast_bridge_call(qe->chan, peer, allowredir_in, allowredir_out, allowdisconnect);
|
||||||
|
|
||||||
|
if(bridge != AST_PBX_NO_HANGUP_PEER)
|
||||||
ast_hangup(peer);
|
ast_hangup(peer);
|
||||||
|
|
||||||
if( bridge == 0 ) res=1; /* JDG: bridge successfull, leave app_queue */
|
if( bridge == 0 ) res=1; /* JDG: bridge successfull, leave app_queue */
|
||||||
else res = bridge; /* bridge error, stay in the queue */
|
else res = bridge; /* bridge error, stay in the queue */
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,7 @@ extern char *ast_pickup_ext(void);
|
|||||||
|
|
||||||
//! Bridge a call, optionally allowing redirection
|
//! Bridge a call, optionally allowing redirection
|
||||||
|
|
||||||
extern int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allowredirect, int allowdisconnect);
|
extern int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allowredirect_in, int allowredirect_out, int allowdisconnect);
|
||||||
|
|
||||||
extern unsigned int ast_get_group(char *s);
|
extern unsigned int ast_get_group(char *s);
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@ extern "C" {
|
|||||||
|
|
||||||
//! Special return values from applications to the PBX
|
//! Special return values from applications to the PBX
|
||||||
#define AST_PBX_KEEPALIVE 10 /* Destroy the thread, but don't hang up the channel */
|
#define AST_PBX_KEEPALIVE 10 /* Destroy the thread, but don't hang up the channel */
|
||||||
|
#define AST_PBX_NO_HANGUP_PEER 11
|
||||||
|
|
||||||
//! Special Priority for an hint
|
//! Special Priority for an hint
|
||||||
#define PRIORITY_HINT -1
|
#define PRIORITY_HINT -1
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <asterisk/parking.h>
|
#include <asterisk/parking.h>
|
||||||
#include <asterisk/musiconhold.h>
|
#include <asterisk/musiconhold.h>
|
||||||
#include <asterisk/config.h>
|
#include <asterisk/config.h>
|
||||||
|
#include <asterisk/cli.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -120,7 +121,11 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (x <= parking_stop) {
|
if (x <= parking_stop) {
|
||||||
|
chan->appl = "Parked Call";
|
||||||
|
chan->data = NULL;
|
||||||
|
|
||||||
pu->chan = chan;
|
pu->chan = chan;
|
||||||
|
/* Start music on hold */
|
||||||
ast_moh_start(pu->chan, NULL);
|
ast_moh_start(pu->chan, NULL);
|
||||||
gettimeofday(&pu->start, NULL);
|
gettimeofday(&pu->start, NULL);
|
||||||
pu->parkingnum = x;
|
pu->parkingnum = x;
|
||||||
@@ -144,7 +149,6 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
|
|||||||
ast_verbose(VERBOSE_PREFIX_2 "Parked %s on %d\n", pu->chan->name, pu->parkingnum);
|
ast_verbose(VERBOSE_PREFIX_2 "Parked %s on %d\n", pu->chan->name, pu->parkingnum);
|
||||||
if (peer)
|
if (peer)
|
||||||
ast_say_digits(peer, pu->parkingnum, "", peer->language);
|
ast_say_digits(peer, pu->parkingnum, "", peer->language);
|
||||||
/* Start music on hold */
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "No more parking spaces\n");
|
ast_log(LOG_WARNING, "No more parking spaces\n");
|
||||||
@@ -188,7 +192,7 @@ int ast_masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, int
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allowredirect, int allowdisconnect)
|
int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allowredirect_in, int allowredirect_out, int allowdisconnect)
|
||||||
{
|
{
|
||||||
/* Copy voice back and forth between the two channels. Give the peer
|
/* Copy voice back and forth between the two channels. Give the peer
|
||||||
the ability to transfer calls with '#<extension' syntax. */
|
the ability to transfer calls with '#<extension' syntax. */
|
||||||
@@ -198,13 +202,17 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allo
|
|||||||
char newext[256], *ptr;
|
char newext[256], *ptr;
|
||||||
int res;
|
int res;
|
||||||
struct ast_option_header *aoh;
|
struct ast_option_header *aoh;
|
||||||
|
struct ast_channel *transferer;
|
||||||
|
struct ast_channel *transferee;
|
||||||
|
char *transferer_real_context;
|
||||||
|
|
||||||
/* Answer if need be */
|
/* Answer if need be */
|
||||||
if (ast_answer(chan))
|
if (ast_answer(chan))
|
||||||
return -1;
|
return -1;
|
||||||
peer->appl = "Bridged Call";
|
peer->appl = "Bridged Call";
|
||||||
peer->data = chan->name;
|
peer->data = chan->name;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
res = ast_channel_bridge(chan, peer, (allowdisconnect ? AST_BRIDGE_DTMF_CHANNEL_0 : 0) + (allowredirect ? AST_BRIDGE_DTMF_CHANNEL_1 : 0), &f, &who);
|
res = ast_channel_bridge(chan, peer, (allowdisconnect||allowredirect_out ? AST_BRIDGE_DTMF_CHANNEL_0 : 0) + (allowredirect_in ? AST_BRIDGE_DTMF_CHANNEL_1 : 0), &f, &who);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", chan->name, peer->name);
|
ast_log(LOG_WARNING, "Bridge failed on channels %s and %s\n", chan->name, peer->name);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -245,23 +253,45 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allo
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
if ((f->frametype == AST_FRAME_DTMF) && (who == peer) && allowredirect &&
|
|
||||||
|
if ((f->frametype == AST_FRAME_DTMF) &&
|
||||||
|
((allowredirect_in && who == peer) || (allowredirect_out && who == chan)) &&
|
||||||
(f->subclass == '#')) {
|
(f->subclass == '#')) {
|
||||||
|
if(allowredirect_in && who == peer) {
|
||||||
|
transferer = peer;
|
||||||
|
transferee = chan;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
transferer = chan;
|
||||||
|
transferee = peer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use the non-macro context to transfer the call */
|
||||||
|
if(strlen(transferer->macrocontext))
|
||||||
|
transferer_real_context=transferer->macrocontext;
|
||||||
|
else
|
||||||
|
transferer_real_context=transferer->context;
|
||||||
|
|
||||||
/* Start autoservice on chan while we talk
|
/* Start autoservice on chan while we talk
|
||||||
to the peer */
|
to the originator */
|
||||||
ast_autoservice_start(chan);
|
ast_autoservice_start(transferee);
|
||||||
|
ast_moh_start(transferee, NULL);
|
||||||
|
|
||||||
memset(newext, 0, sizeof(newext));
|
memset(newext, 0, sizeof(newext));
|
||||||
ptr = newext;
|
ptr = newext;
|
||||||
|
|
||||||
/* Transfer */
|
/* Transfer */
|
||||||
if ((res=ast_streamfile(peer, "pbx-transfer", peer->language))) {
|
if ((res=ast_streamfile(transferer, "pbx-transfer", transferer->language))) {
|
||||||
ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
|
ast_autoservice_stop(transferee);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((res=ast_waitstream(peer, AST_DIGIT_ANY)) < 0) {
|
if ((res=ast_waitstream(transferer, AST_DIGIT_ANY)) < 0) {
|
||||||
ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
|
ast_autoservice_stop(transferee);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ast_stopstream(peer);
|
ast_stopstream(transferer);
|
||||||
if (res > 0) {
|
if (res > 0) {
|
||||||
/* If they've typed a digit already, handle it */
|
/* If they've typed a digit already, handle it */
|
||||||
newext[0] = res;
|
newext[0] = res;
|
||||||
@@ -270,65 +300,77 @@ int ast_bridge_call(struct ast_channel *chan, struct ast_channel *peer, int allo
|
|||||||
}
|
}
|
||||||
res = 0;
|
res = 0;
|
||||||
while(strlen(newext) < sizeof(newext) - 1) {
|
while(strlen(newext) < sizeof(newext) - 1) {
|
||||||
res = ast_waitfordigit(peer, 3000);
|
res = ast_waitfordigit(transferer, 3000);
|
||||||
if (res < 1)
|
if (res < 1)
|
||||||
break;
|
break;
|
||||||
if (res == '#')
|
if (res == '#')
|
||||||
break;
|
break;
|
||||||
*(ptr++) = res;
|
*(ptr++) = res;
|
||||||
if (!ast_matchmore_extension(peer, peer->context, newext, 1, peer->callerid)) {
|
if (!ast_matchmore_extension(transferer, transferer_real_context
|
||||||
|
, newext, 1, transferer->callerid)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
|
ast_autoservice_stop(transferee);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!strcmp(newext, ast_parking_ext())) {
|
if (!strcmp(newext, ast_parking_ext())) {
|
||||||
if (ast_autoservice_stop(chan))
|
ast_moh_stop(transferee);
|
||||||
|
|
||||||
|
if (ast_autoservice_stop(transferee))
|
||||||
res = -1;
|
res = -1;
|
||||||
else if (!ast_park_call(chan, peer, 0, NULL)) {
|
else if (!ast_park_call(transferee, transferer, 0, NULL)) {
|
||||||
/* We return non-zero, but tell the PBX not to hang the channel when
|
/* We return non-zero, but tell the PBX not to hang the channel when
|
||||||
the thread dies -- We have to be careful now though. We are responsible for
|
the thread dies -- We have to be careful now though. We are responsible for
|
||||||
hanging up the channel, else it will never be hung up! */
|
hanging up the channel, else it will never be hung up! */
|
||||||
|
|
||||||
|
if(transferer==peer)
|
||||||
res=AST_PBX_KEEPALIVE;
|
res=AST_PBX_KEEPALIVE;
|
||||||
|
else
|
||||||
|
res=AST_PBX_NO_HANGUP_PEER;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
ast_log(LOG_WARNING, "Unable to park call %s\n", chan->name);
|
ast_log(LOG_WARNING, "Unable to park call %s\n", transferee->name);
|
||||||
}
|
}
|
||||||
/* XXX Maybe we should have another message here instead of invalid extension XXX */
|
/* XXX Maybe we should have another message here instead of invalid extension XXX */
|
||||||
} else if (ast_exists_extension(chan, peer->context, newext, 1, peer->callerid)) {
|
} else if (ast_exists_extension(transferee, transferer_real_context, newext, 1, transferer->callerid)) {
|
||||||
res=ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
if (!chan->pbx) {
|
res=ast_autoservice_stop(transferee);
|
||||||
|
if (!transferee->pbx) {
|
||||||
/* Doh! Use our handy async_goto funcitons */
|
/* Doh! Use our handy async_goto funcitons */
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Transferring %s to '%s' (context %s) priority 1\n", chan->name, chan->exten, chan->context);
|
ast_verbose(VERBOSE_PREFIX_3 "Transferring %s to '%s' (context %s) priority 1\n"
|
||||||
if (ast_async_goto(chan, peer->context, newext, 1, 1))
|
,transferee->name, newext, transferer_real_context);
|
||||||
|
if (ast_async_goto(transferee, transferer_real_context, newext, 1, 1))
|
||||||
ast_log(LOG_WARNING, "Async goto fialed :(\n");
|
ast_log(LOG_WARNING, "Async goto fialed :(\n");
|
||||||
} else {
|
} else {
|
||||||
/* Set the channel's new extension, since it exists, using peer context */
|
/* Set the channel's new extension, since it exists, using transferer context */
|
||||||
strncpy(chan->exten, newext, sizeof(chan->exten)-1);
|
strncpy(transferee->exten, newext, sizeof(transferee->exten)-1);
|
||||||
strncpy(chan->context, peer->context, sizeof(chan->context)-1);
|
strncpy(transferee->context, transferer_real_context, sizeof(transferee->context)-1);
|
||||||
chan->priority = 0;
|
transferee->priority = 0;
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Unable to find extension '%s' in context %s\n", newext, peer->context);
|
ast_verbose(VERBOSE_PREFIX_3 "Unable to find extension '%s' in context '%s'\n", newext, transferer_real_context);
|
||||||
}
|
}
|
||||||
res = ast_streamfile(peer, "pbx-invalid", chan->language);
|
res = ast_streamfile(transferer, "pbx-invalid", transferee->language);
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
|
ast_autoservice_stop(transferee);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
res = ast_waitstream(peer, AST_DIGIT_ANY);
|
res = ast_waitstream(transferer, AST_DIGIT_ANY);
|
||||||
ast_stopstream(peer);
|
ast_stopstream(transferer);
|
||||||
res = ast_autoservice_stop(chan);
|
ast_moh_stop(transferee);
|
||||||
|
res = ast_autoservice_stop(transferee);
|
||||||
if (res) {
|
if (res) {
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "Hungup during autoservice stop on '%s'\n", chan->name);
|
ast_verbose(VERBOSE_PREFIX_2 "Hungup during autoservice stop on '%s'\n", transferee->name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (f && (f->frametype == AST_FRAME_DTMF)) {
|
if (f && (f->frametype == AST_FRAME_DTMF)) {
|
||||||
@@ -498,7 +540,7 @@ static int park_exec(struct ast_channel *chan, void *data)
|
|||||||
were the person called. */
|
were the person called. */
|
||||||
if (option_verbose > 2)
|
if (option_verbose > 2)
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Channel %s connected to parked call %d\n", chan->name, park);
|
ast_verbose(VERBOSE_PREFIX_3 "Channel %s connected to parked call %d\n", chan->name, park);
|
||||||
res = ast_bridge_call(peer, chan, 1, 0);
|
res = ast_bridge_call(peer, chan, 1, 1, 0);
|
||||||
/* Simulate the PBX hanging up */
|
/* Simulate the PBX hanging up */
|
||||||
if (res != AST_PBX_KEEPALIVE)
|
if (res != AST_PBX_KEEPALIVE)
|
||||||
ast_hangup(peer);
|
ast_hangup(peer);
|
||||||
@@ -520,6 +562,37 @@ static int park_exec(struct ast_channel *chan, void *data)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int handle_parkedcalls(int fd, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct parkeduser *cur;
|
||||||
|
|
||||||
|
ast_cli(fd, "%4s %25s (%-15s %-12s %-4s) %-6s \n", "Num", "Channel"
|
||||||
|
, "Context", "Extension", "Pri", "Timeout");
|
||||||
|
|
||||||
|
ast_pthread_mutex_lock(&parking_lock);
|
||||||
|
|
||||||
|
cur=parkinglot;
|
||||||
|
while(cur) {
|
||||||
|
ast_cli(fd, "%4d %25s (%-15s %-12s %-4d) %6ds\n"
|
||||||
|
,cur->parkingnum, cur->chan->name, cur->context, cur->exten
|
||||||
|
,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
|
||||||
|
|
||||||
|
cur = cur->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
ast_pthread_mutex_unlock(&parking_lock);
|
||||||
|
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char showparked_help[] =
|
||||||
|
"Usage: show parkedcalls\n"
|
||||||
|
" Lists currently parked calls.\n";
|
||||||
|
|
||||||
|
static struct ast_cli_entry showparked =
|
||||||
|
{ { "show", "parkedcalls", NULL }, handle_parkedcalls, "Lists parked calls", showparked_help };
|
||||||
|
|
||||||
|
|
||||||
int load_module(void)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@@ -529,6 +602,9 @@ int load_module(void)
|
|||||||
char exten[AST_MAX_EXTENSION];
|
char exten[AST_MAX_EXTENSION];
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
struct ast_variable *var;
|
struct ast_variable *var;
|
||||||
|
|
||||||
|
ast_cli_register(&showparked);
|
||||||
|
|
||||||
cfg = ast_load("parking.conf");
|
cfg = ast_load("parking.conf");
|
||||||
if (cfg) {
|
if (cfg) {
|
||||||
var = ast_variable_browse(cfg, "general");
|
var = ast_variable_browse(cfg, "general");
|
||||||
@@ -641,6 +717,9 @@ unsigned int ast_get_group(char *s)
|
|||||||
int unload_module(void)
|
int unload_module(void)
|
||||||
{
|
{
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
|
|
||||||
|
ast_cli_unregister(&showparked);
|
||||||
|
|
||||||
return ast_unregister_application(parkedcall);
|
return ast_unregister_application(parkedcall);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user