Thu Feb 13 07:00:00 CET 2003
authorMatteo Brancaleoni <mbrancaleoni@espia.it>
Thu, 13 Feb 2003 06:00:14 +0000 (06:00 +0000)
committerMatteo Brancaleoni <mbrancaleoni@espia.it>
Thu, 13 Feb 2003 06:00:14 +0000 (06:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@613 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
channels/chan_zap.c
pbx.c
pbx/pbx_config.c

index 9818b27..93d8777 100755 (executable)
@@ -797,7 +797,7 @@ static int sip_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
        return -1;
 }
 
-static struct ast_channel *sip_new(struct sip_pvt *i, int state)
+static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
 {
        struct ast_channel *tmp;
        int fmt;
@@ -807,7 +807,10 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state)
                if (!tmp->nativeformats)
                        tmp->nativeformats = capability;
                fmt = ast_best_codec(tmp->nativeformats);
-               snprintf(tmp->name, sizeof(tmp->name), "SIP/%s:%d", inet_ntoa(i->sa.sin_addr), ntohs(i->sa.sin_port));
+               if (title)
+                       snprintf(tmp->name, sizeof(tmp->name), "SIP/%s", title);
+               else
+                       snprintf(tmp->name, sizeof(tmp->name), "SIP/%s:%d", inet_ntoa(i->sa.sin_addr), ntohs(i->sa.sin_port));
                tmp->type = type;
                tmp->fds[0] = ast_rtp_fd(i->rtp);
                ast_setstate(tmp, state);
@@ -2256,6 +2259,7 @@ static int check_user(struct sip_pvt *p, struct sip_request *req, char *cmd, cha
                                strncpy(p->context, user->context, sizeof(p->context) - 1);
                                if (strlen(user->callerid) && strlen(p->callerid)) 
                                        strncpy(p->callerid, user->callerid, sizeof(p->callerid) - 1);
+                               strncpy(p->username, user->name, sizeof(p->username) - 1);
                                strncpy(p->accountcode, user->accountcode, sizeof(p->accountcode)  -1);
                                p->canreinvite = user->canreinvite;
                                p->amaflags = user->amaflags;
@@ -2992,7 +2996,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                /* Initialize tag */    
                                p->tag = rand();
                                /* First invitation */
-                               c = sip_new(p, AST_STATE_DOWN);
+                               c = sip_new(p, AST_STATE_DOWN, strlen(p->username) ? p->username : NULL);
                        }
                        
                } else 
@@ -3388,7 +3392,7 @@ static struct ast_channel *sip_request(char *type, int format, void *data)
 #if 0
        printf("Setting up to call extension '%s' at '%s'\n", ext ? ext : "<none>", host);
 #endif
-       tmpc = sip_new(p, AST_STATE_DOWN);
+       tmpc = sip_new(p, AST_STATE_DOWN, host);
        if (!tmpc)
                sip_destroy(p);
        restart_monitor();
index 5244bbe..45f6aed 100755 (executable)
@@ -3560,6 +3560,10 @@ static void *ss_thread(void *data)
        case SIG_FXOKS:
                /* Read the first digit */
                timeout = firstdigittimeout;
+               /* If starting a threeway call, never timeout on the first digit so someone
+                  can use flash-hook as a "hold" feature */
+               if (p->subs[SUB_THREEWAY].owner) 
+                       timeout = 999999;
                while(len < AST_MAX_EXTENSION-1) {
                        res = ast_waitfordigit(chan, timeout);
                        timeout = 0;
@@ -3570,7 +3574,7 @@ static void *ss_thread(void *data)
                                return NULL;
                        } else if (res)  {
                                exten[len++]=res;
-                               exten[len] = '\0';
+               exten[len] = '\0';
                        }
                        if (!ast_ignore_pattern(chan->context, exten))
                                tone_zone_play_tone(p->subs[index].zfd, -1);
diff --git a/pbx.c b/pbx.c
index 59cb83b..ba3d2bc 100755 (executable)
--- a/pbx.c
+++ b/pbx.c
@@ -145,6 +145,7 @@ static int pbx_builtin_ringing(struct ast_channel *, void *);
 static int pbx_builtin_congestion(struct ast_channel *, void *);
 static int pbx_builtin_busy(struct ast_channel *, void *);
 static int pbx_builtin_setvar(struct ast_channel *, void *);
+static int pbx_builtin_setglobalvar(struct ast_channel *, void *);
 static int pbx_builtin_noop(struct ast_channel *, void *);
 static int pbx_builtin_gotoif(struct ast_channel *, void *);
 void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
@@ -259,10 +260,14 @@ static struct pbx_builtin {
 "  Busy(): Requests that the channel indicate busy condition and then waits\n"
 "for the user to hang up.  Always returns -1." },
 
-       { "Setvar", pbx_builtin_setvar,
+       { "SetVar", pbx_builtin_setvar,
 "Set variable to value",
 "  Setvar(#n=value): Sets variable n to value" },
 
+       { "SetGlobalVar", pbx_builtin_setglobalvar,
+"Set variable to value",
+"  Setvar(#n=value): Sets global variable n to value" },
+
        { "NoOp", pbx_builtin_noop,
 "No operation",
 "  NoOp(): No-operation; Does nothing." },
@@ -3580,6 +3585,27 @@ static int pbx_builtin_setvar(struct ast_channel *chan, void *data)
         return(0);
 }
 
+static int pbx_builtin_setglobalvar(struct ast_channel *chan, void *data)
+{
+       char *name;
+       char *value;
+       char *stringp=NULL;
+                
+       if (!data || !strlen(data)) {
+               ast_log(LOG_WARNING, "Ignoring, since there is no variable to set\n");
+               return 0;
+       }
+       
+       stringp=data;
+       name=strsep(&stringp,"=");
+       value=strsep(&stringp,"\0"); 
+       
+       pbx_builtin_setvar_helper(NULL,name,value);
+                       
+        return(0);
+}
+
+
 static int pbx_builtin_noop(struct ast_channel *chan, void *data)
 {
        return 0;
index 56de6ed..ab25438 100755 (executable)
@@ -1510,10 +1510,10 @@ static int pbx_load_module(void)
                                                        if (!pri)
                                                                pri="";
                                                        appl = stringp;
-                                                       if (!(start = strchr(appl, '(')))
-                                                               appl = strsep(&stringp, ",");
                                                        if (!appl)
                                                                appl="";
+                                                       if (!(start = strchr(appl, '(')))
+                                                               appl = strsep(&stringp, ",");
                                                        if (start && (end = strrchr(appl, ')'))) {
                                                                *start = *end = '\0';
                                                                data = start + 1;
@@ -1588,7 +1588,10 @@ int load_module(void)
 int reload(void)
 {
        ast_context_destroy(NULL, registrar);
+       /* For martin's global variables, don't clear them on reload */
+#if 0
        pbx_builtin_clear_globals();
+#endif 
        pbx_load_module();
        return 0;
 }