]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
sig_analog: Add Last Number Redial feature.
authorNaveen Albert <asterisk@phreaknet.org>
Fri, 10 Nov 2023 13:30:33 +0000 (08:30 -0500)
committerNaveen Albert <asterisk@phreaknet.org>
Thu, 16 Jan 2025 15:47:22 +0000 (15:47 +0000)
This adds the Last Number Redial feature to
simple switch.

UserNote: Users can now redial the last number
called if the lastnumredial setting is set to yes.

Resolves: #437

channels/chan_dahdi.c
channels/chan_dahdi.h
channels/sig_analog.c
channels/sig_analog.h
configs/samples/chan_dahdi.conf.sample

index f2960ef0a1a9a8e7b8611053c38a7f2183da97a3..e2a0117e3aebc5fffd0c8732c20d3cb5b5d0e7bd 100644 (file)
@@ -13109,6 +13109,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                tmp->permhidecallerid = conf->chan.hidecallerid;
                tmp->hidecalleridname = conf->chan.hidecalleridname;
                tmp->callreturn = conf->chan.callreturn;
+               tmp->lastnumredial = conf->chan.lastnumredial; /* Not used in DAHDI pvt, only analog pvt */
                tmp->echocancel = conf->chan.echocancel;
                tmp->echotraining = conf->chan.echotraining;
                tmp->pulse = conf->chan.pulse;
@@ -13404,6 +13405,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                                analog_p->permcallwaiting = conf->chan.callwaiting; /* permcallwaiting possibly modified in analog_config_complete */
                                analog_p->calledsubscriberheld = conf->chan.calledsubscriberheld; /* Only actually used in analog pvt, not DAHDI pvt */
                                analog_p->callreturn = conf->chan.callreturn;
+                               analog_p->lastnumredial = conf->chan.lastnumredial; /* Only actually used in analog pvt, not DAHDI pvt */
                                analog_p->cancallforward = conf->chan.cancallforward;
                                analog_p->canpark = conf->chan.canpark;
                                analog_p->dahditrcallerid = conf->chan.dahditrcallerid;
@@ -18653,6 +18655,8 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
                        parse_busy_pattern(v, &confp->chan.busy_cadence);
                } else if (!strcasecmp(v->name, "calledsubscriberheld")) {
                        confp->chan.calledsubscriberheld = ast_true(v->value);
+               } else if (!strcasecmp(v->name, "lastnumredial")) {
+                       confp->chan.lastnumredial = ast_true(v->value);
                } else if (!strcasecmp(v->name, "callprogress")) {
                        confp->chan.callprogress &= ~CALLPROGRESS_PROGRESS;
                        if (ast_true(v->value))
index 4431efd9136e2f8891d7a4becc50f713367b3458..72bd234f848ea682248b418f04ab149fa8d3e0b2 100644 (file)
@@ -440,6 +440,8 @@ struct dahdi_pvt {
         * \note Used by SS7.  Otherwise set but not used.
         */
        unsigned int inservice:1;
+       /*! *\brief TRUE if last number redial enabled */
+       unsigned int lastnumredial:1;
        /*!
         * \brief Bitmask for the channel being locally blocked.
         * \note Applies to SS7 and MFCR2 channels.
index e23cf072c4a9c2bd00107198b35f5e9277724e71..e477d5d0cf54f172942364c886d207be8c951388 100644 (file)
@@ -1721,6 +1721,9 @@ static int analog_canmatch_featurecode(const char *pickupexten, const char *exte
        if (extlen < strlen(pickupexten) && !strncmp(pickupexten, exten, extlen)) {
                return 1;
        }
+       if (exten[0] == '#' && extlen < 2) {
+               return 1; /* Could match ## */
+       }
        /* hardcoded features are *60, *67, *69, *70, *72, *73, *78, *79, *82, *0 */
        if (exten[0] == '*' && extlen < 3) {
                if (extlen == 1) {
@@ -2208,6 +2211,19 @@ static void *__analog_ss_thread(void *data)
                        if (ast_parking_provider_registered()) {
                                is_exten_parking = ast_parking_is_exten_park(ast_channel_context(chan), exten);
                        }
+                       if (p->lastnumredial && !strcmp(exten, "##") && !ast_exists_extension(chan, ast_channel_context(chan), "##", 1, p->cid_num)) {
+                               /* Last Number Redial */
+                               if (!ast_strlen_zero(p->lastexten)) {
+                                       ast_verb(4, "Redialing last number dialed on channel %d\n", p->channel);
+                                       ast_copy_string(exten, p->lastexten, sizeof(exten));
+                               } else {
+                                       ast_verb(3, "Last Number Redial not possible on channel %d (no saved number)\n", p->channel);
+                                       res = analog_play_tone(p, idx, ANALOG_TONE_CONGESTION);
+                                       analog_wait_event(p);
+                                       ast_hangup(chan);
+                                       goto quit;
+                               }
+                       }
                        if (ast_exists_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num) && !is_exten_parking) {
                                if (!res || !ast_matchmore_extension(chan, ast_channel_context(chan), exten, 1, p->cid_num)) {
                                        if (getforward) {
@@ -2230,6 +2246,11 @@ static void *__analog_ss_thread(void *data)
                                                ast_channel_lock(chan);
                                                ast_channel_exten_set(chan, exten);
 
+                                               /* Save the last number dialed, for Last Number Redial. */
+                                               if (!p->immediate) {
+                                                       ast_copy_string(p->lastexten, exten, sizeof(p->lastexten));
+                                               }
+
                                                /* Properly set the presentation.
                                                 * We need to do this here as well, because p->hidecallerid might be set
                                                 * due to permanent blocking, not star-67/star-82 usage. */
index 81043f39a58c4119ac7a3483fb043945a9165798..023170cf7f274abe1130d6da95d2922656e5a399 100644 (file)
@@ -297,6 +297,7 @@ struct analog_pvt {
        unsigned int hanguponpolarityswitch:1;
        unsigned int immediate:1;
        unsigned int immediatering:1;                   /*!< TRUE if ringing should be provided for immediate execution */
+       unsigned int lastnumredial:1;                   /*!< TRUE if last number redial allowed */
        unsigned int permcallwaiting:1;                 /*!< TRUE if call waiting is enabled. (Configured option) */
        unsigned int permhidecallerid:1;                /*!< Whether to hide our outgoing caller ID or not */
        unsigned int pulse:1;
@@ -352,6 +353,7 @@ struct analog_pvt {
        char callwait_name[AST_MAX_EXTENSION];
        char lastcid_num[AST_MAX_EXTENSION];
        char lastcid_name[AST_MAX_EXTENSION];
+       char lastexten[AST_MAX_EXTENSION];      /*!< Last number dialed */
        struct ast_party_caller caller;
        int redirecting_reason;                 /*!< Redirecting reason */
 
index f36fe56ce328e252bc783fc53d20a63cae5703b8..21c7954e1f43a03e03ef434fb69f95b11eb6a061 100644 (file)
@@ -814,6 +814,11 @@ cancallforward=yes
 ;
 callreturn=yes
 ;
+; Whether or not to allow redialing the last number called using Last Number Redial
+; (##, if your dialplan doesn't catch this first)
+;
+;lastnumredial=yes
+;
 ; Stutter dialtone support: If voicemail is received in the mailbox then
 ; taking the phone off hook will cause a stutter dialtone instead of a
 ; normal one.