Fix queue URL passing (bug #3543)
authorMark Spencer <markster@digium.com>
Mon, 28 Feb 2005 06:06:42 +0000 (06:06 +0000)
committerMark Spencer <markster@digium.com>
Mon, 28 Feb 2005 06:06:42 +0000 (06:06 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5104 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_dial.c
channel.c
channels/chan_local.c
channels/iax2-parser.c
frame.c

index 3920ba4..ed2979e 100755 (executable)
@@ -149,6 +149,7 @@ static char *rdescrip =
 #define DIAL_GO_ON                                     (1 << 10)
 #define DIAL_HALT_ON_DTMF                      (1 << 11)
 #define DIAL_PRESERVE_CALLERID         (1 << 12)
+#define DIAL_NOFORWARDHTML                     (1 << 13)
 
 struct localuser {
        struct ast_channel *chan;
@@ -328,7 +329,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
                                        if (option_verbose > 2)
                                                ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
                                        peer = o->chan;
-                                       ast_copy_flags(peerflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT);
+                                       ast_copy_flags(peerflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT|DIAL_NOFORWARDHTML);
                                }
                        } else if (o->chan && (o->chan == winner)) {
                                if (!ast_strlen_zero(o->chan->call_forward)) {
@@ -440,7 +441,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
                                                                if (option_verbose > 2)
                                                                        ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
                                                                peer = o->chan;
-                                                               ast_copy_flags(peerflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT);
+                                                               ast_copy_flags(peerflags, o, DIAL_ALLOWREDIRECT_IN|DIAL_ALLOWREDIRECT_OUT|DIAL_ALLOWDISCONNECT_IN|DIAL_ALLOWDISCONNECT_OUT|DIAL_NOFORWARDHTML);
                                                        }
                                                        /* If call has been answered, then the eventual hangup is likely to be normal hangup */
                                                        in->hangupcause = AST_CAUSE_NORMAL_CLEARING;
@@ -504,14 +505,16 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
                                                        ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
                                                }
                                        } else if (single && (f->frametype == AST_FRAME_VOICE) && 
-                                                               !(ast_test_flag(outgoing, DIAL_RINGBACKONLY) || ast_test_flag(outgoing, DIAL_MUSICONHOLD))) {
+                                                               !(ast_test_flag(outgoing, DIAL_RINGBACKONLY|DIAL_MUSICONHOLD))) {
                                                if (ast_write(in, f)) 
                                                        ast_log(LOG_WARNING, "Unable to forward frame\n");
                                        } else if (single && (f->frametype == AST_FRAME_IMAGE) && 
-                                                               !(ast_test_flag(outgoing, DIAL_RINGBACKONLY) || ast_test_flag(outgoing, DIAL_MUSICONHOLD))) {
+                                                               !(ast_test_flag(outgoing, DIAL_RINGBACKONLY|DIAL_MUSICONHOLD))) {
                                                if (ast_write(in, f))
                                                        ast_log(LOG_WARNING, "Unable to forward image\n");
-                                       }
+                                       } else if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag(outgoing, DIAL_NOFORWARDHTML))
+                                               ast_channel_sendhtml(in, f->subclass, f->data, f->datalen);
+
                                        ast_frfree(f);
                                } else {
                                        in->hangupcause = o->chan->hangupcause;
@@ -564,6 +567,11 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu
                                }
                        }
 
+                       /* Forward HTML stuff */
+                       if (single && f && (f->frametype == AST_FRAME_HTML) && !ast_test_flag(outgoing, DIAL_NOFORWARDHTML)) 
+                               ast_channel_sendhtml(outgoing->chan, f->subclass, f->data, f->datalen);
+                       
+
                        if (single && ((f->frametype == AST_FRAME_VOICE) || (f->frametype == AST_FRAME_DTMF)))  {
                                if (ast_write(outgoing->chan, f))
                                        ast_log(LOG_WARNING, "Unable to forward voice\n");
@@ -906,6 +914,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                        ast_set2_flag(tmp, strchr(transfer, 'h'), DIAL_ALLOWDISCONNECT_IN);
                        ast_set2_flag(peerflags, strchr(transfer, 'h'), DIAL_ALLOWDISCONNECT_IN);
                        ast_set2_flag(tmp, strchr(transfer, 'f'), DIAL_FORCECALLERID);  
+                       ast_set2_flag(tmp, url, DIAL_NOFORWARDHTML);    
                        ast_set2_flag(peerflags, strchr(transfer, 'w'), DIAL_MONITOR_IN);       
                        ast_set2_flag(peerflags, strchr(transfer, 'W'), DIAL_MONITOR_OUT);      
                        ast_set2_flag(peerflags, strchr(transfer, 'd'), DIAL_HALT_ON_DTMF);     
index 3cc5d67..b9e63f1 100755 (executable)
--- a/channel.c
+++ b/channel.c
@@ -1659,6 +1659,14 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
        case AST_FRAME_TEXT:
                if (chan->pvt->send_text)
                        res = chan->pvt->send_text(chan, (char *) fr->data);
+               else
+                       res = 0;
+               break;
+       case AST_FRAME_HTML:
+               if (chan->pvt->send_html)
+                       res = chan->pvt->send_html(chan, fr->subclass, (char *) fr->data, fr->datalen);
+               else
+                       res = 0;
                break;
        case AST_FRAME_VIDEO:
                /* XXX Handle translation of video codecs one day XXX */
@@ -2832,6 +2840,7 @@ int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, struct as
                        (f->frametype == AST_FRAME_TEXT) ||
                        (f->frametype == AST_FRAME_VIDEO) || 
                        (f->frametype == AST_FRAME_IMAGE) ||
+                       (f->frametype == AST_FRAME_HTML) ||
                        (f->frametype == AST_FRAME_DTMF)) {
                        if ((f->frametype == AST_FRAME_DTMF) && 
                                (config->flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))) {
index e6ee964..288a418 100755 (executable)
@@ -139,7 +139,7 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
 {
        if (p->alreadymasqed || p->nooptimization)
                return;
-       if (isoutbound && p->chan && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && p->owner) {
+       if (isoutbound && p->chan && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && p->owner && !p->owner->pvt->readq) {
                /* Masquerade bridged channel into owner */
                /* Lock everything we need, one by one, and give up if
                   we can't get everything.  Remember, we'll get another
@@ -152,7 +152,7 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
                        }
                        ast_mutex_unlock(&(p->chan->_bridge)->lock);
                }
-       } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan) {
+       } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && !p->chan->pvt->readq) {
                /* Masquerade bridged channel into chan */
                if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
                        if (!ast_mutex_trylock(&p->chan->lock)) {
@@ -233,6 +233,22 @@ static int local_digit(struct ast_channel *ast, char digit)
        return res;
 }
 
+static int local_sendhtml(struct ast_channel *ast, int subclass, char *data, int datalen)
+{
+       struct local_pvt *p = ast->pvt->pvt;
+       int res = -1;
+       struct ast_frame f = { AST_FRAME_HTML, };
+       int isoutbound;
+       ast_mutex_lock(&p->lock);
+       isoutbound = IS_OUTBOUND(ast, p);
+       f.subclass = subclass;
+       f.data = data;
+       f.datalen = datalen;
+       res = local_queue_frame(p, isoutbound, &f, ast);
+       ast_mutex_unlock(&p->lock);
+       return res;
+}
+
 static int local_call(struct ast_channel *ast, char *dest, int timeout)
 {
        struct local_pvt *p = ast->pvt->pvt;
@@ -436,6 +452,8 @@ static struct ast_channel *local_new(struct local_pvt *p, int state)
                tmp2->pvt->pvt = p;
                tmp->pvt->send_digit = local_digit;
                tmp2->pvt->send_digit = local_digit;
+               tmp->pvt->send_html = local_sendhtml;
+               tmp2->pvt->send_html = local_sendhtml;
                tmp->pvt->call = local_call;
                tmp2->pvt->call = local_call;
                tmp->pvt->hangup = local_hangup;
index 6adc684..edc15ec 100755 (executable)
@@ -375,7 +375,9 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
                "NULL   ",
                "IAX    ",
                "TEXT   ",
-               "IMAGE  " };
+               "IMAGE  ",
+               "HTML   ",
+               "CNG    " };
        char *iaxs[] = {
                "(0?)",
                "NEW    ",
@@ -447,7 +449,7 @@ void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, s
                /* Don't mess with mini-frames */
                return;
        }
-       if (fh->type > (int)sizeof(frames)/(int)sizeof(frames[0])) {
+       if (fh->type >= (int)sizeof(frames)/(int)sizeof(frames[0])) {
                snprintf(class2, (int)sizeof(class2), "(%d?)", fh->type);
                class = class2;
        } else {
diff --git a/frame.c b/frame.c
index 22e02c0..3cf54ee 100755 (executable)
--- a/frame.c
+++ b/frame.c
@@ -354,7 +354,7 @@ struct ast_frame *ast_fr_fdread(int fd)
        /* Forget about being mallocd */
        f->mallocd = 0;
        /* Re-write the source */
-       f->src = __FUNCTION__;
+       f->src = (char *)__FUNCTION__;
        if (f->datalen > sizeof(buf) - sizeof(struct ast_frame)) {
                /* Really bad read */
                ast_log(LOG_WARNING, "Strange read (%d bytes)\n", f->datalen);