Restore Dial, Queue, and FollowMe 'I' option support.
[asterisk/asterisk.git] / res / parking / parking_bridge_features.c
index de06dd9..0e5e05d 100644 (file)
@@ -40,7 +40,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/say.h"
 #include "asterisk/datastore.h"
 #include "asterisk/stasis.h"
+#include "asterisk/module.h"
 #include "asterisk/core_local.h"
+#include "asterisk/causes.h"
 
 struct parked_subscription_datastore {
        struct stasis_subscription *parked_subscription;
@@ -314,7 +316,8 @@ static int parking_blind_transfer_park(struct ast_bridge_channel *bridge_channel
                        return -1;
                }
 
-               if (ast_bridge_impart(bridge_channel->bridge, transfer_chan, NULL, NULL, 1)) {
+               if (ast_bridge_impart(bridge_channel->bridge, transfer_chan, NULL, NULL,
+                       AST_BRIDGE_IMPART_CHAN_INDEPENDENT)) {
                        ast_hangup(transfer_chan);
                        return -1;
                }
@@ -444,6 +447,8 @@ static int parking_park_call(struct ast_bridge_channel *parker, char *exten, siz
 
 static int feature_park_call(struct ast_bridge_channel *bridge_channel, void *hook_pvt)
 {
+       SCOPED_MODULE_USE(parking_get_module_info()->self);
+
        return parking_park_call(bridge_channel, NULL, 0);
 }
 
@@ -480,7 +485,8 @@ static int parking_duration_callback(struct ast_bridge_channel *bridge_channel,
        user->resolution = PARK_TIMEOUT;
        ao2_unlock(user);
 
-       ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
+       ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE,
+               AST_CAUSE_NORMAL_CLEARING);
 
        /* Set parking timeout channel variables */
        snprintf(parking_space, sizeof(parking_space), "%d", user->parking_space);
@@ -568,14 +574,17 @@ void say_parking_space(struct ast_bridge_channel *bridge_channel, const char *pa
        if (sscanf(payload, "%u %u", &hangup_after, &numeric_value) != 2) {
                /* If say_parking_space is called with a non-numeric string, we have a problem. */
                ast_assert(0);
-               ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
+               ast_bridge_channel_leave_bridge(bridge_channel,
+                       BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
                return;
        }
 
-       ast_say_digits(bridge_channel->chan, numeric_value, "", ast_channel_language(bridge_channel->chan));
+       ast_say_digits(bridge_channel->chan, numeric_value, "",
+               ast_channel_language(bridge_channel->chan));
 
        if (hangup_after) {
-               ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE);
+               ast_bridge_channel_leave_bridge(bridge_channel,
+                       BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, AST_CAUSE_NORMAL_CLEARING);
        }
 }
 
@@ -599,9 +608,9 @@ void parking_set_duration(struct ast_bridge_features *features, struct parked_us
        /* The interval hook is going to need a reference to the parked_user */
        ao2_ref(user, +1);
 
-       if (ast_bridge_interval_hook(features, time_limit,
+       if (ast_bridge_interval_hook(features, 0, time_limit,
                parking_duration_callback, user, __ao2_cleanup, AST_BRIDGE_HOOK_REMOVE_ON_PULL)) {
-               ast_log(LOG_ERROR, "Failed to apply duration limits to the parking call.\n");
+               ast_log(LOG_ERROR, "Failed to apply duration limit to the parked call.\n");
                ao2_ref(user, -1);
        }
 }
@@ -623,10 +632,15 @@ void unload_parking_bridge_features(void)
 
 int load_parking_bridge_features(void)
 {
+       parking_provider.module_info = parking_get_module_info();
+
        if (ast_parking_register_bridge_features(&parking_provider)) {
                return -1;
        }
 
-       ast_bridge_features_register(AST_BRIDGE_BUILTIN_PARKCALL, feature_park_call, NULL);
+       if (ast_bridge_features_register(AST_BRIDGE_BUILTIN_PARKCALL, feature_park_call, NULL)) {
+               return -1;
+       }
+
        return 0;
 }