ensure that parking context/extension (and other settings) are properly updated on...
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 13 Oct 2005 23:58:33 +0000 (23:58 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 13 Oct 2005 23:58:33 +0000 (23:58 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6780 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_features.c

index 8ee672a..87fe851 100755 (executable)
@@ -77,35 +77,35 @@ static char *parkedcall = "ParkedCall";
 static int parkingtime = DEFAULT_PARK_TIME;
 
 /* Context for which parking is made accessible */
-static char parking_con[AST_MAX_EXTENSION] = "parkedcalls";
+static char parking_con[AST_MAX_EXTENSION];
 
 /* Context for dialback for parking (KLUDGE) */
-static char parking_con_dial[AST_MAX_EXTENSION] = "park-dial";
+static char parking_con_dial[AST_MAX_EXTENSION];
 
 /* Extension you type to park the call */
-static char parking_ext[AST_MAX_EXTENSION] = "700";
+static char parking_ext[AST_MAX_EXTENSION];
 
-static char pickup_ext[AST_MAX_EXTENSION] = "*8";
+static char pickup_ext[AST_MAX_EXTENSION];
 
 /* Default sounds */
-static char courtesytone[256] = "";
-static char xfersound[256] = "beep";
-static char xferfailsound[256] = "pbx-invalid";
+static char courtesytone[256];
+static char xfersound[256];
+static char xferfailsound[256];
 
 /* First available extension for parking */
-static int parking_start = 701;
+static int parking_start;
 
 /* Last available extension for parking */
-static int parking_stop = 750;
+static int parking_stop;
 
-static int parking_offset = 0;
+static int parking_offset;
 
-static int parkfindnext = 0;
+static int parkfindnext;
 
-static int adsipark = 0;
+static int adsipark;
 
-static int transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
-static int featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
+static int transferdigittimeout;
+static int featuredigittimeout;
 
 /* Default courtesy tone played when party joins conference */
 
@@ -1816,6 +1816,12 @@ static int handle_showfeatures(int fd, int argc, char *argv[])
                }
                AST_LIST_UNLOCK(&feature_list);
        }
+       ast_cli(fd, "\nCall parking\n");
+       ast_cli(fd, "------------\n");
+       ast_cli(fd,"%-20s:      %s\n", "Parking extension", parking_ext);
+       ast_cli(fd,"%-20s:      %s\n", "Parking context", parking_con);
+       ast_cli(fd,"%-20s:      %d-%d\n", "Parked call extensions", parking_start, parking_stop);
+       ast_cli(fd,"\n");
        
        return RESULT_SUCCESS;
 }
@@ -1945,7 +1951,26 @@ static int load_config(void)
        struct ast_context *con = NULL;
        struct ast_config *cfg = NULL;
        struct ast_variable *var = NULL;
-       
+       char old_parking_ext[AST_MAX_EXTENSION];
+       char old_parking_con[AST_MAX_EXTENSION];
+
+       if (!ast_strlen_zero(parking_con)) {
+               strcpy(old_parking_ext, parking_ext);
+               strcpy(old_parking_con, parking_con);
+       } 
+
+       /* Reset to defaults */
+       strcpy(parking_con, "parkedcalls");
+       strcpy(parking_con_dial, "park-dial");
+       strcpy(parking_ext, "700");
+       strcpy(pickup_ext, "*8");
+       courtesytone[0] = '\0';
+       strcpy(xfersound, "beep");
+       strcpy(xferfailsound, "pbx-invalid");
+       parking_start = 701;
+       parking_stop = 750;
+       parkfindnext = 0;
+
        transferdigittimeout = DEFAULT_TRANSFER_DIGIT_TIMEOUT;
        featuredigittimeout = DEFAULT_FEATURE_DIGIT_TIMEOUT;
 
@@ -2083,9 +2108,11 @@ static int load_config(void)
        }
        ast_config_destroy(cfg);
 
-       
-       if (con)
-               ast_context_remove_extension2(con, ast_parking_ext(), 1, registrar);
+       /* Remove the old parking extension */
+       if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con)))     {
+               ast_context_remove_extension2(con, old_parking_ext, 1, registrar);
+               ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
+       }
        
        if (!(con = ast_context_find(parking_con))) {
                if (!(con = ast_context_create(NULL, parking_con, registrar))) {
@@ -2105,6 +2132,8 @@ int load_module(void)
        int res;
        
        AST_LIST_HEAD_INIT(&feature_list);
+       memset(parking_ext, 0, sizeof(parking_ext));
+       memset(parking_con, 0, sizeof(parking_con));
 
        if ((res = load_config()))
                return res;