[asterisk-users] Prevent Dial if any extension is busy

Leif Neland leifn at neland.dk
Mon Nov 30 02:51:53 CST 2009


Leif Neland wrote:
>> But my problem comes when I speak on 0317998985 and someone calls on 
>> 985, the call
>> get to my celluar phone and ofc the other way around.
>>
>> Is there a way to check if any extension is busy and in that case 
>> jump to VoiceMail(0317998985 at inputinterior.se,b)?
>
> If both phones were directly connected sip, it could be done.
> The problem is that you can't determine if the cellular is busy before 
> you call it.
> ...
> The other option is to modify the source, and add an option to the 
> dial-command, to exit if any extension dialled is busy.
> After all, this is open source :-)
>
> Leif
>
I think a modification should be done around here to return busy if just 
one channel was busy (only enabled if an option on dial is set)
in asterisk-1.6.0.15/apps/app_dial.c, line 610

Is somebody willing to try?

while (*to && !peer) {
        struct chanlist *o;
        int pos = 0; /* how many channels do we handle */
        int numlines = prestart;
        struct ast_channel *winner;
        struct ast_channel *watchers[AST_MAX_WATCHERS];

        watchers[pos++] = in;
        for (o = outgoing; o; o = o->next) {
            /* Keep track of important channels */
            if (ast_test_flag64(o, DIAL_STILLGOING) && o->chan)
                watchers[pos++] = o->chan;
            numlines++;
        }
        if (pos == 1) { /* only the input channel is available */
            if (numlines == (num.busy + num.congestion + num.nochan)) {
                ast_verb(2, "Everyone is busy/congested at this time 
(%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
                if (num.busy)
                    strcpy(pa->status, "BUSY");
                else if (num.congestion)
                    strcpy(pa->status, "CONGESTION");
                else if (num.nochan)
                    strcpy(pa->status, "CHANUNAVAIL");
            } else {
                ast_verb(3, "No one is available to answer at this time 
(%d:%d/%d/%d)\n", numlines, num.busy, num.congestion, num.nochan);
            }
            *to = 0;
            return NULL;
        }

Preferably, either the dialcommand should be preceeded with a 
ChanIsAvail on the sip first, as there is no need to place a toll-call 
to the cell if the sip is busy. Or the dialcommand itself should have an 
option to delay one or more of the calls in the dialstring 
(Dial(Technology/resource[&Tech2/resource2...]). But this would probably 
be too messy...


Leif

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091130/34fe881a/attachment.htm 


More information about the asterisk-users mailing list